int main(void) { int ch; while (ch = getchar() != EOF) putchar(ch); }Does this program copy its input to its output, or what? (Note: see operator precedence)
If you're thinking of taking CPSC 223, please do the following.
New addition: C In a Nutshell, (2nd edition) Chapters 1-7.
We have added the public tests for assignment 1. In addition, we have met ULAs and scheduled office hours. The office hours are Sun/Tue/Thu 8-11 PM at Hillhouse 17 Rm 111. Also, we will hold a tutorial to cover zoo and UNIX fundamentals from 7-8 PM this Sunday.
$ /c/cs223/bin/submit 1 Makefile time.log Total.c invalid group:My initial instinct was to blame myself. (That's just me. I have been married for 30 years, so it is usually the best strategy.) My ultimate diagnosis was:$ /c/cs223/bin/check 1 invalid group:
OK. The script looks to see if you have a directory in /c/cs223/class If not, you are UNKNOWN. You need to set up your zoo account with the zookeepeer: : https://ivy.yale.edu/zookeeper/It looks like that fixed the problem. Let me know if it recurs.
I, like many of you, have reviewed the evaluations for this course from last semester. You are enrolled today because of or in spite of those comments. Be that as it may, I am taking the suggestions seriously. I intend to address the following issues this semester. (Some of the reported bugs were intended as features, e.g., using tech interview questions on exams.)
I don't think C gets enough credit. Sure, C doesn't love you. C isn't about love--C is about thrills. C hangs around in the bad part of town. C knows all the gang signs. C has a motorcycle, and wears the leathers everywhere, and never wears a helmet, because that would mess up C's punked-out hair. C likes to give cops the finger and grin and speed away. Mention that you'd like something, and C will pretend to ignore you; the next day, C will bring you one, no questions asked, and toss it to you with a you-know-you-want-me smirk that makes your heart race. Where did C get it? "It fell off a truck," C says, putting away the boltcutters. You start to feel like C doesn't know the meaning of "private" or "protected": what C wants, C takes. This excites you. C knows how to get you anything but safety. C will give you anything but commitment. In the end, you'll leave C, not because you want something better, but because you can't handle the intensity. C says "I'm gonna live fast, die young, and leave a good-looking corpse," but you know that C can never die, not so long as C is still the fastest thing on the road
We conclude with a discussion of the simple C program for counting characters in standard input. This is the basis for the first homework assignment. s17h1.v0.
See /c/cs223/hw1. Specifically, check out the sample file /c/cs223/hw1/Total.c
You are encouraged to expand on the algorithm for atoi() to implement Total.c. In particular, you need to handle a variety of bases: 10, 8, 16, and 2. K&R pdf section 2.7, page 61. Remember that you do not need to handle floating point numbers or scientific notation.
## get version number gcc --version ## get warnings. Produce a.out gcc -Wall Total.c ## get warnings. Produce Total gcc -Wall -o Total Total.c ## preprocessing to standard output gcc -E Total.c ## preprocessing to file gcc -E -o Total.i Total.c ## preprocessing, do not remove comments gcc -E -C -o Total.i Total.c ## compile, but do not assemble. gcc -S Total.c ## compile, but do not assemble. Leave C names as comments gcc -S -fverbose-asm Total.c ## compile, produce object file: Total.o gcc -c Total.c ## compile, link in the math library gcc -o Total -lm Total.c
A C program may comprise multiple header (.h), source (.c), object (.o), and library (.a) files. If the .o file is older than the .c or .h files on which it depends, you need to recompile. If not, the .o file is up to date.
make knows which file is older than others by looking at the modification date. You can fool make using the touch command. For example, if you want to recompile a .o file even if the .c file older, you can touch the .c file.
You inform make of these dependencies with the makefile