Difference between revisions of "StartingC"

From SourceWiki
Jump to navigation Jump to search
Line 7: Line 7:
  
 
=A Quintessential Start=
 
=A Quintessential Start=
 +
 +
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:
  
 
<pre>
 
<pre>
Line 12: Line 14:
 
</pre>
 
</pre>
  
we will be using make
+
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):
  
 
<pre>
 
<pre>
Line 18: Line 20:
 
</pre>
 
</pre>
  
and run the classic program
+
Now, we can run the classic program:
  
 
<pre>
 
<pre>
 
./hello.exe
 
./hello.exe
 
</pre>
 
</pre>
 +
 +
and you should get the friendly response:
 +
 +
<pre>
 +
hello, world!
 +
</pre>
 +
 +
Bingo!  We've just surmounted the hardest step in way--running our first C program.  Given this quantum leap, everything else will boil down to the consideration of details, really.
  
 
=Types=
 
=Types=

Revision as of 16:15, 18 August 2009

startingC: Learning the C Programming Language

svn co http://source.ggy.bris.ac.uk/subversion-open/startingC/trunk ./startingC

A Quintessential Start

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 the hardest step in way--running our first C program. Given this quantum leap, everything else will boil down to the consideration of details, really.

Types

int char float double

short & long

sizeof() casting

enumerated types

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