Main Content

Some new C programming examples - files, structs, unions etc

Archive - Originally posted on "The Horse's Mouth" - 2007-12-19 07:57:03 - Graham Ellis

A series of new "C" examples have been added to the web site - a course for a small group allowed me to go somewhat away from the more normal run yesterday and write some new illustrations in front of them.

Call by value v call by pointer comparison: link

Using extern to share a variable between two different sources: link and link

Handling command line parameters through pointers: link

Structures, and pointers to structures: link and link

Unions, where memory is shared between variables: link

File handling through open and read, fopen and fgets compared: link and link

And some C++ examples:

Fomatting floating point numbers in C++: link

Using a vector (in effect an object that's an array but can be extended as required: link

All examples have comments and sample outputs included and will open in a new window if you click on the links. All simple examples, and they're often the best!