CS156: Introduction to C
This is the home page for CS156, Introduction to C,
a class in the Computer Science Department
at CSU.
Click on the sidebar, on the left, for other class pages.
Announcements
Grades are posted
Grades have been posted. Run ~cs156/bin/grade to find out how you did.
HW4 solution
The solution to HW4 is here.
HW4: Return type of get_stats is wrong
In HW4, I got the return type of get_stats wrong—it should
be void, not int:
void get_stats(char fn[]);
HW3: parameters to calculate_interest:
In HW3, the description of the required function calculate_interest
erroneously stated that the first parameter was a year.
It should, instead, be a book 'number, 1–14.
HW3: Strange formats
If you copied HW3’s main from the assignment before noon Sunday,
double-check your scanf formats. Make sure they don’t have any
extra dots in them:
Good:
scanf("%c%*c", &cmd); // Read command, ignore enter key
scanf("%d%*c", &year);
scanf("%d%f%*c", &booknum, &price);
Bad:
scanf("%c.%*c", &cmd); // Read command, ignore enter key
scanf("%d.%*c", &year);
scanf("%d.%f.%*c", &booknum, &price);
HW3: Book Number
I've added the following to the HW3 specification:
- You may assume that the user will enter a number 1–14 when prompted for a book number.
HW1: Example Was Wrong
In HW1, the sample output for 113 and 355 was flawed–it printed out the last digit of the
first number, instead of the second number. It’s fixed, now.
HW1: Read the Specifications
HW1 states: “You may ONLY use two int variables in your entire
program. No other variables, of any type, are allowed.” So far,
three people have turned HW1, and two of the three submissions have
violated this rule. This is not a good sign.
Favorite Editor
The last question of the CS155 final exam was
“What’s your favorite editor? Why?” Here are the answers:
| pico | 36 | notepad | 2 | my brain | 1 |
| vi/vim/gvim | 14 | OpenOffice | 2 | xcode | 1 |
| emacs | 3 | blue | 2 | The editor in chief | 1 |
| gedit | 2 | none | 2 | sed | 1 |
Some of my favorite reasons “Why?”:
- pico, cause it starts with the letter “p”, of course!
- pico because I said so
- pico, because I am using a mac (different keyboard)
- vim because it is like word
- vi—I like a challenge
- emacs; I know how to save & exit
- notepad; because I am a masochist
- Blue! Because it’s the color of my water
- I don’t have a favorite editor because I really dislike Unix
and just want to go back to using windows!
- See you next semester!
Homework counts more
In CS156, homework is 40% of your grade. In CS155, it was only 20%.
Syntax Highlighting
Both emacs and vi provides mechanisms for highlighting C syntax, such
that it is easy to differentiate between keywords, comments, variables,
etc. In emacs, select “Options” and click on “Syntax Highlighting
(Global Font Lock Mode)”. In vi, enter, “:syntax on”. Also consider
using gvim instead of vi or vim.