CS113: Introduction to C

Fall Semester 2005
When: August 26 - September 23 MWF 12:20 - 1:10p
Where: Olin Hall 245
Instructor: Erik Sherwood
Email: wes28 - at - cs.cornell.edu
Office: 657 Rhodes Hall
Office hours: WEDNESDAY 2:30 - 4, or by appointment
Grading: S/U only

Announcements | Assignments | Lecture Notes and Schedule | Course Info | Useful links

Announcements

9/22 - One more error in the lists.c file (this time a typo in the previous correction) has been corrected: make the second call to strtok look like "word = strtok(NULL,"\n");". The source code for lists.c has been updated with this second correction. Thanks to Tony for catching it.

9/21 - There was a mistake in the lists.c file for the final assignment. Strings with spaces were not read in correctly (for the add command). This has been corrected; download the new lists.c file from the same link as before. If you have already gotten started, the change is to add a the declaration "char* word" at the top of main() and then modify the code between the lines "while(1)" and "if (strcmp(command,"help") == 0)" as in the updated lists.c file. My apologies for the bug, and thanks to Jeff for catching it.

9/19 - The final homework assignment is due Monday, September 26 at 5 p.m. There will be no further extensions. Also, there will be no lecture this Friday, September 23. If you have questions, you can see me in 657 Rhodes during the normal lecture time.

9/15 - Function pointers have been added to the lecture 6 notes.

9/15 - There is a small correction to the source code provided for assignment 3. (There was a typo in the delete_string prototype.) Thanks to Kevin for pointing it out.

9/15 - For the quiz tomorrow, any material up to this Monday's lecture, not including file handling, is fair game. The quiz will consist of 4 to 5 short program listings; you will be asked to write the output or explain why the program won't work. They should not be particularly hard. You should not spend more than 90 minutes reviewing for the quiz. (Function pointer notes should be up this evening. My apologies for taking so long.)

9/12 - Actually, the final homework is available now -- before noon.

9/11 - The final homework should be available Monday afternoon.

9/11 - The remaining lecture notes have been posted. They do not include everything we have talked about concerning function pointers and the preprocessor. I plan to update the notes by Wednesday. Also, the lectures may not follow the order presented below; I may decide to cover dynamic memory allocation earlier.

9/7 - I may be slightly late to office hours today, but I will be there by 2:45. Also, I will leave promptly at 4 to attend a talk, so if you have unanswered questions, we can arrange another time to meet (Thursday or Friday afternoon), or you can send me email.

9/7 - If you know you are going to be late handing in an assignment (for whatever reason), notify me as soon as possible. The earlier I know, the better. Not handing in assignments on time and then trying to make them up at the end of the course will not work.

9/3 - I have posted the second homework. Instead of having an optional challenge problem, I have included a problem that may require slightly more thought than normal. All of the problems in homework 2 should be turned in. Also, when turning in printouts of your homework solutions, staple all of the pages together. 9/1 - If you want me to look over any code at office hours, please email it to me before coming to my office.

8/25 - The add/drop deadline for this course is Friday, September 2, one week after the first class meeting.

Top

Assignments

Homework 0 - due ASAP!
Homework 1 - due Friday, September 2
Homework 2 - due Friday, September 9
In Class Quiz - Friday, September 16
Homework 3 - due Friday, September 23

Homeworks should be submitted by 5 p.m. on the due date. You must turn in a PRINTOUT of your program(s) with your full name and netID either in class or in my mailbox in 657 Rhodes and email the source code to me. You do not need to submit any sample output for your programs. Follow the instructions included for each homework when naming the source code files that you submit.

Top

Lecture Notes and Schedule

This is a tentative schedule: the course plan may change, and the lectures may not follow the notes.

Lecture 1: Course details, example C programs
Reading: PCP Chapter 1; K&R Chapter 1 up to 1.8 inclusive

Lecture 2: Control statements
Reading: PCP Chapters 4,6,8; K&R Chapter 3 up to 3.7 inclusive

Lecture 3: Variables, data types, operators
Reading: K&R Chapter 2

Lecture 4: Functions and function activation records
Reading: PCP Chapter 9; K&R Chapter 4.1, 4.2

Lecture 5: Pointers and memory management
Reading: PCP Chapters 9 and 13

Lecture 6: Arrays, pointers, and strings
Reading: PCP Chapters 5, 13; K&R Chapter 5

Lecture 7: The C preprocessor, I/O in C
Reading: PCP Chapters 10, 14; K&R Chapter 7

Lecture 8: Type definitions and structures
Reading: PCP Chaters 12; K&R Chapter 6

Lecture 9: Dynamic memory allocation, dynamic data structures
Reading: PCP Chapter 17; K&R Section 7.8.5

Top

Course Info

Course Content

The goal of this course is to teach the fundamentals of the C programming language. By the end of this course, a student should have sufficient mastery so that details of the language not discussed in the class can be learned independently by reading a book (such as "The C Programming Language" by Kernighan and Ritchie). In addition, by the end of the course students should feel comfortable writing simple C programs, and have working experience with all major C features.

I will assume that you have taken a college-level programming course at the level of CS100.

Please do not take this class if you do not anticipate being able to attend the lectures, or if you don't think that you'll be able to turn in all of the assignments on time.

All auditors/visitors are welcome.

Textbooks

There are two recommended textbooks for this course: Practical C Programming, by Steve Oualline, and The C Programming Language, Second Edition by Brian Kernighan and Dennis Ritchie. The first book is available online as a networked resource from the Cornell library, and both are on reserve at the engineering library. You aren't required to purchase either book. The Oualline book is probably a better introduction, though it has its problems, while the K & R book is a better reference for long-term use. C: A Reference Manual, by Samuel Harbison and Guy Steele, is also excellent if you anticipate doing much C programming in the future, but it is probably overkill to buy it just for this course. It is also on reserve at the engineering library.

Newsgroup

There is a newsgroup for the course: cornell.class.cs113. The Cornell newsgroup server is newsstand.cit.cornell.edu. If you have questions of a general nature, please post them to the newsgroup. (To post messages, use your NetID and your NetID password when prompted.)

Compiler

In this course, you may use any compiler that compiles ANSI C code. In particular, you may use the gcc compiler that is standard with UNIX/Linux/MacOSX. If you have access to gcc and you have a good text editor like emacs (or are willing to use Notepad), this option is much easier and simpler than using CodeWarrior.

Here are instructions to help you get started writing a C program using CodeWarrior on a PC (version 8):

  1. Load the CodeWarrior IDE. It is found under Start->All Programs->Class Files->Codewarrior on the CIT lab computers.
  2. Select File:New.
  3. Select "Win32 C Stationery" under Project, enter a project name, and then click OK.
  4. Select Win32 WinSIOUX App, and click OK.
  5. Click on the plus to the left of "Source", and then double-click on main.c.
  6. Now you're cooking. Edit main.c to your heart's content. To run or debug your program, click on the green arrows in the project window, or alternatively select Project:Run or Project:Debug.
  7. Don't forget to save your file periodically!
Here's a guide to CodeWarrior (in postscript format). Note that it was written for Macintosh users, so some parts may be Macintosh specific.

Collaboration

You may discuss your work with classmates on a high level but the work you turn in must be your own. You should definitely understand everything that you turn in as if you had done all the work yourself. You can help classmates debug their code, but you should not write code for anyone else, nor should you use code that others have written for you. If you have any questions about this policy, please ask me. The Cornell University Code of Academic Integrity provides more details on these issues.

Keep in mind that CS113 is a self-selecting, noncompetitive course, so cheating is particularly pointless, given the associated risks.

Top

Helpful links

C/C++ Standard Library Reference Page

comp.lang.c FAQ

Memory Management Glossary

Top