Central Connecticut State University Spring, 1999 CS 216 -- C Programming in the Unix Environment-- 3 Credits Section 70 Tue, Thur 06:45 -- 08:00 PM Room 209 Maria Sanford Hall Instructor: Dr. Charles W. Neville Course Description: This is a course in the UNIX operating system and the C programming language for students with a substantial programming background. UNIX is a Multi-User, Multi-Tasking operating system which has set the standard for operating systems since its inception, and still sets the standard today. C is a Structured programming language which has been the language of choice for most serious application developers since its inception, and still is the language of choice today. Students will be expected to complete a substantial number of operating system and programming projects. Students will program in the GNU gcc programming environment using the vi or emacs editor on Berkeley UNIX or higher programming machines. Students will hand in operating system and programming projects by emailing the source code FROM A UNIX MACHINE to me at the email address given below. Students will also hand in hard copy in a folder WITH POCKETS. Each student will be given an account on one of the CS Department's NeXT machines, which run Berkeley UNIX on top of the Mach operating system kernel. Students will access these machines by telnetting from home, or from the University Microcomputer laboratory. Students will restrict themselves to the UNIX command line environment. (The proprietary NeXT graphical user interface environment is no longer accessible from the Microlab.) Students who wish to work at home on Intel architecture machines (PC's) may also purchase a CD version of Linux, a free public domain version of UNIX, from various book and software stores, including Barnes and Noble, The Other Bookstore, and Borders Books and Music. At some of these stores, the student may have to place a special order. Linux is free on the internet, but it is MUCH easier to install it from a CD ROM. Finally, there is the UNIX Installfest at the Yale School of Management on Saturday, January 30. For more information, consult the notice posted on one of the Department's bulletin boards, or consult http://www.cfug.org. (No period at the end of the URL.) Required Texts: UNIX for the MS - DOS User, by Kenneth Pugh, Prentice Hall, 1994, Paper, ISBN 0-13-146077-3 The C Programming Language, 2nd edition, by Brian Kernighan and Dennis Ritchie, Prentice Hall, 1989, Paper, ISBN 0-13-110362-8 The student will need a number of folders WITH POCKETS in which to hand in programming project assignments. Prerequisite: CS 152 or CS 213. Course Objectives: Upon successful completion of the UNIX portion of the course, the student will 1. Understand and use the basic UNIX commands 2. Understand and use the UNIX hierarchical file system 3. Understand and use the UNIX user shell, environment and shell variables, and IO redirection 4. Understand and use the vi and emacs editors 5. Understand and use groups, users and file permissions. 6. Understand and use multitasking from a user's point of view, including background and foreground processes, and starting a process at a later time. 7. Understand and use elementary shell scripts and shell programming. 8. Understand and use the basic UNIX tools, including pattern searching with regular expressions, sed (the UNIX stream editor), sorting, comparing files, viewing the heads and tails of files, etc. 9. Understand and use the Bourne shell and the C shell, including scripts with control structures (if, for, while, etc.) Upon successful completion of the C portion of the course, the student will: 1. Understand the basic structure of C programs. 2. Understand and use the basic C control structures, such as if ... else, switch, while, do, for, and break. 3. Understand and use the basic C data types. 4. Understand and write C functions. 5. Pass parameters to C functions, both by value and by reference. 6. Understand and use C arrays. 7. Understand and use C structures and unions. 8. Write significant application programs in C. Assignments and Exams: Reading and project assignments are listed below. Exam dates are denoted by **. Make-up exams are scheduled by appointment only. Project due dates are listed below. Mini-assignments should be done, but do not need to be handed in. Grading: Your final grade will be based on computer projects and in-class exams, and will be affected by classroom participation, conduct and attendance. The exams will include questions from the textbook and computer project assignments. The numerical grades for the exams will be averaged and then converted to a letter grade. Attendance: Two unexcused absences are allowed, and any work missed must be made up. The student should notify the instructor concerning absences, or there will be a grade penalty. Student Conduct. It is expected that all students will conduct themselves in a respectful manner, and will assist in maintaining an atmosphere conducive to learning in the classroom. Honesty Policy. It is expected that all students will conduct themselves in an honorable and honest manner. It is alright to give and receive help on projects, but no student may claim another's work as his or her own, and no student may have another student's program in his or her possession. Students may use code from published sources, but if a student uses code from a source other than class or the text, the student should provide a reference in comments. Office Hours: MWF 12:00 -- 12:50 PM and TR 4:15 -- 5:10 PM, or by appointment, especially before and after class. Feel free to stay for help, and feel free to stay to chat. My office is in room 205 Maria Sanford Hall. In an emergency, email me at neville@ccsu.edu, (no comma at the end of the email address) or call me at 832-2719 (work). My Web page URL (Web address) is http://www.cs.ccsu.ctstateu.edu/~neville. (Again, no period at the end of the URL.) Week No. Reading and Project Assignments 1. 1/26 Begin UNIX: Chapter 1, Introduction to UNIX; Chapter 2, Files and Directories. Mini-assignment:, Chapter 1 and 2 Workouts. 2. 2/2 Chapter 3, The shell; Chapter 4, vi; Chapter 5 emacs. Mini-assignment: Chapter 3, 4 , and 5 Workouts. (You may wish to do the next mini-assignment before doing the chapter 5 workouts. Mini-assignment: The COMPLETE emacs on-line tutorial, done by entering emacs and typing CTRL h t 3. 2/9 Chapters 6, Other Users; Chapter 7, Multitasking. Mini-assignment: Chapter 6 and 7 Workouts. 2/11** UNIX Quiz 1 4. 2/16 Chapter 8, Shell Programming. Mini-assignment: Chapter 8 Workouts. 5. 2/23 Chapter 9, Tools. Mini-assignment: Chapter 9 Workouts. 6. 3/2 Chapter 10, The Bourne Shell (as time permits); Chapter 11, The C Shell. Mini-assignment: Chapter 10 Workouts. Mini-assignment: Chapter 11 Workouts. 7. 3/9 Chapter 11 continued. Finish the last mini-assignment. 3/11** UNIX Hour Exam 8. 3/16 Begin C: Chapter 1, A Tutorial Introduction Mini-assignment:Do Exercise 1-3, p. 13: Modify the temperature conversion program to print a header above the table. 3/22 to 3/26 Spring Recess, No Classes! 9. 3/30 Chapter 1 continued. Mini-assignment: Do Exercise 1-7, p 13: Write a program to print the value of EOF Project 1: Do Exercise 1-14, p. 24: Write a program to print a histogram of the frequencies of different characters in its input. Due 4/6 10. 4/6 Chapter 2, Types, Operators and Expressions Project 2: Do Exercise 2-1, p. 36: Write a program to determine the ranges of char, short, int, and long variables, both signed and unsigned by printing appropriate values from the standard headers and by direct computation. Due 4/13 11. 4/13** C Quiz 1 Chapter 3, Control Flow Mini-assignment: Do Exercise 3-4, p. 64: In a two's complement number representation, our version of itoa does not handle the largest negative number, that is the value of n equal to -(2wordsize - 1). Explain why not. Modify it to print the value correctly, regardless of the machine on which it is run. 12. 4/20 Chapter 5, Pointers and Arrays Project 3: This is Exercise 5-10, sort of. Write a program that adds up the values on its command line. So, for example, if the executable is named addup, addup 12 34 56 will print out 102, whereas addup -63 87 prints out 24. (Stolen from Bradley Kjell). Due 4/27 13. 4/27 Chapter 5 continued Mini-assignment: Do Exercise 5-3, p. 107: Write a pointer version of the function strcat we showed in Chapter 2; strcat(s, t) copies the string t to the end of s. 14. 5/4 Chapter 6, Structures Project 4: Do Exercise 6-3, p. 143: Write a cross-reference that prints a list of all words in a document, and, for each word, a list of the line numbers on which it occurs. Remove noise words like "the", "and", and so on. Due 5/18 15. 5/11 Chapter 6 continued 5/13 Reading Day, No Classes! 16. 5/18 Review 5/20** Final Exam, 5:15 -- 6:30 PM Have a Good Summer!