[oclug] C Tutorials

Greg Franks greg at cr1004769-a.slnt1.on.wave.home.com
Mon Aug 27 11:29:50 EDT 2001


Short answer: Just get the newer version of K&R for the intro.

>>>>> "Sandy" == Sandy Harris <sandy at storm.ca> writes:
    >> Will I be lead too far off the beaten path by studying K&R C?

    Sandy> Probably, yes.

But in reality no.  The differences of note are:

The thing ANSI added that most people really use are the function
prototypes.   This is a really good thing.  In K&R (original), just
convert:

  foo( a, b )
  int a;
  int b;
  { ... }

to 

  void foo( int a, int b )
  { ... }

(you may have to return ints instead -- check for returns).

You will have to declare "void foo( int a, int b );" before the
function foo is referenced.  This is most often done in "#include"
files. 

ANSI also added structure copying and passing structs as args, but big
deal.  Most people still do memcpy( &a, &d, sizeof( a ) ); instead of
a=b; anyway.  Passing and returning structs is generally frowned upon
because it impacts performance.

ANSI also added some really horrid features like "tri-graphs".  Best
to avoid these.
-- 
   __@               Greg Franks              <|       _~@ __O 
 _`\<,_         Ottawa, Ontario, Canada        |O\   -^\<;^\<, 
(*)/ (*)                                       (*)--(*)%---/(*)
          "Where do you want to go today?"   Outside.  



More information about the OCLUG mailing list