Difference between revisions of "StartingC"
Line 34: | Line 34: | ||
</pre> | </pre> | ||
− | Bingo! We've just surmounted | + | Bingo! We've just surmounted--in some ways--our hardest step; running our first C program. Given this quantum leap, everything else will be plain sailing from here, honest! |
=Types & Operations= | =Types & Operations= |
Revision as of 09:02, 21 August 2009
startingC: Learning the C Programming Language
Introduction
svn co http://source.ggy.bris.ac.uk/subversion-open/startingC/trunk ./startingC
A Quintessential First Program
OK, now that we have the example code, let's get cracking and run our first C program. First of all, move into the example directory:
cd startingC/examples/example1
We'll use of a Makefile for each example, so as to make the build process painless (hopefully!). All we need do is run make (see the [make tutorial about make] if you're interested in this further):
make
Now, we can run the classic program:
./hello.exe
and you should get the friendly response:
hello, world!
Bingo! We've just surmounted--in some ways--our hardest step; running our first C program. Given this quantum leap, everything else will be plain sailing from here, honest!
Types & Operations
int char float double
short & long
sizeof() casting
enumerated types
Now, it's very important that you muck around with these example programs as much as possible! Ideally, so much so that you break them! We never learn as much as when we make a mess of things, and since these are just toy programs, you may as well go for it! If you get in a pickle, you can get the original programs back with a quick waft of the Subversion wand:
svn revert *
Exercises
types.c
- do this
- then that
operations.c
- this
- that
The C Preprocessor
Loops & Conditionals
if then else
(switch) case (default - fall through)
while and for
break & continue
Functions & Header Files
Arrays & Pointers
address, dereference address arith 2d arrays binary trees and linked lists - just give examples
Structures
DAB again
watch out for padding
The Command Line and I/O
Further Reading
The bible is The C Programming Language by Kernighan & Ritchie.