learning C (53)

1 Name: #!usr/bin/anon 2005-04-11 11:42 ID:CwnpYNPT

could someone suggest good place to learn C ? or maybe i should go with C++ ? i know some other languages ( Ruby, PHP, OCaml, Smalltalk, Delphi, C#, VB... ) so no need for tutorials that explain what is variable and how to use 'if' and such...

2 Name: !WAHa.06x36 2005-04-11 12:08 ID:3WfI3O5K

Might be good to learn C first. C++ is admittedly a bit of a mess, and it might be easier to find your way around if you know C first.

Out of the languages you mentioned, PHP and C# are probably closest, syntax-wise. It's been a long time since I learned it and I just picked up a book at random and read it, so I don't have much good advice for where to learn it. I can point out the things you might want to look at, though:

  • C is fairly strongly typed (although it auto-converts between different types of integers and floats), and I think it is quite similar to C# in that. Variables are only declared at the start of blocks, not in the middle of them (unless you're using C99). C only has functions and no objects. Functions are often declared in a header file with a function prototype.
  • On that note, look into how C include files are built, and how the preprocessor works (#include, #define, #ifndef and so on).
  • Pointers are strange and scary to people not used to them. Look into pointer arithmetic, and the differences and similarities between arrays and pointers (arrays behave much like pointers in most contexts, but arrays have a block of memory associated with them while a pointer can be pointed to whichever block you want). Also, neither arrays nor pointers have any kind of bounds checking, so you can easily overwrite random bits of memory. Be careful with that.
  • structs are compound datatypes much like objects in other languages, but without any methods. Pass-by-reference is popular in other languages, and in C the equivalent is to pass pointers to structs. You can, however, also pass structs themselves, which amounts to copying the contents of the struct.

Well, those are some random unorganized thoughts. Have fun!

3 Name: #!usr/bin/anon 2005-04-13 19:53 ID:b4WVx85q

thanks man... just finished reading Introductory Class Notes ( http://www.eskimo.com/~scs/cclass/notes/ ) which did explain most of that stuff you mentioned now to Intermediate Class Notes ( http://www.eskimo.com/~scs/cclass/int/ ) anything else i should keep eyes open for ? and i was wondering about what magic you need to set up things so that you could ./configure && make && make install ?

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: