CS113: Introduction to C
Spring Semester 2006
When: January 23 - February 17 MWF 12:20 - 1:10p
Where: Hollister 206
Instructor: Erik Sherwood
Email: wes28 - at - cs.cornell.edu
Office: 657 Rhodes Hall
Office hours: TBA
Grading: S/U only
Announcements | Assignments | Lecture Notes and Schedule | Course Info | Useful links
Announcements
2/16 - Several announcements:
- NO LECTURE FRIDAY, FEBRUARY 17. I will hold office hours in Rhodes 657 from 12:15 to 1:30 instead.
- For question 3 of homework 3, my solution for encryption sends lowercase letters to lowercase letters and uppercase letters to uppercase letters. You may find the function isalpha() in ctype.h (part of standard C) useful.
- Read homework 3 carefully. Skeleton driver code is provided for you (via a link). You should be able to make simple modifications to this code, filling in additional functions (with prototypes you might have to write yourself) as needed, as you solve each part.
- You should turn in electronic and printed copies of all of your solutions by 5 p.m. Monday, February 20.
- Slides for lecture 10, which would have been given this Friday, have been posted. If you have questions about them, or about the quiz, ask me at office hours Friday. People with questions about homework 3 will be given priority.
2/13 - Office hours this week: Wednesday 3-4, possibly Friday afternoon (announcement in class).
2/12 - Quiz related announcement: There was a typo in the notes for lecture 6 in the section on arrays of function pointers. I have posted a corrected version. Any questions related to arrays of function pointers on the quiz will not depend on knowledge of the typo or its correction in order for you to answer them correctly.
2/10 - Two announcements:
- The "self-test" on pointers and arrays that we went through in class today is available here.
- Regarding whitespace in question 1, homework 3 (reversing a sentence) -- My solution ignores leading whitespace, then shuffles whitespace between words in the following way: (5spaces)word1(2spaces)word2(3spaces)word3 becomes word3(3spaces)word2(2spaces)word1, where (spaces) indicates the number of space characters between words. Your program should behave similarly. Also, for input of a single word followed by whitespace, like word(5spaces), your output should be drow(5spaces).
2/6 - Office hours this week are Wednesday, 2/8, from 3-4.
2/3 - Regarding homework submissions:
- You MUST hand in a hardcopy of the source code of your programs. The hardcopy must
have your name and netID, and if it is more than one page, it must be stapled. I will not accept
unstapled printouts.
- Give the files you submit by email the same names as indicated in the assignment description.
For problem 4, homework 2:
- I do not care if you use source code you find on the web, etc. to do the sorts. You should
try to understand what the code is doing, though.
- You may find code similar to the following to be useful when reading in
characters indicating the user's desired sorting options:
char c, d
scanf("%c", &c);
scanf("\n%c", &d);
1/31 - Office hours this week: Wednesday 3-4 and by appointment.
1/27 - Compiling and running programs with Windows:
- Several people have asked about which compiler to use with Windows. I suggest using either
Codewarrior, which is available in the undergraduate computer labs (e.g. in the basement of Upson),
or using gcc with cygwin. If you choose the latter option,
instructions for installation and use are available at the cygwin website. I will not provide any
extra tech support for configuring your system, etc.
- For those using Codewarrior, the console window disappears very quickly once a program
finishes, often too quickly for you to be able to tell whether the output was correct. You can
force the console window to stay open by adding the line
system("pause");
to the end of your main function. Please remove or comment out this line before submitting
your homework.
1/25 - Two announcements:
- Recommended texts for the course have been placed on reserve at the Engineering Library (Carpenter); PCP is available online as a networked resource.
- The links to the lecture notes have been fixed.
1/24 - The due date for the first homework is MONDAY, January 30.
1/23 - There are several announcements for the first class:
- The add/drop deadline for this course is Monday, January 30, one week after the first class
meeting.
- Address all email to my CS account: wes28 - at - cs.cornell.edu
- When turning in printouts of your homework solutions, staple all of the pages together.
- If you want me to look over any code at office hours, please email it to me before coming to my office.
- 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.
Top
Assignments
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
Lecture 10:
Odds and Ends
Reading: TBD
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
I do not plan to use the newsgroup for this course. Please direct all questions to me
via email.
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):
- Load the CodeWarrior IDE. It is found under Start->All Programs->Class Files->Codewarrior on the CIT lab computers.
- Select File:New.
- Select "Win32 C Stationery" under Project, enter a project name,
and then click OK.
- Select Win32 WinSIOUX App, and click OK.
- Click on the plus to the left of "Source", and then double-click
on main.c.
- 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.
- 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
Blinky Pointer Fun Movie
Top