Simple C structs - building up to full, dynamic example
Archive - Originally posted on "The Horse's Mouth" - 2014-12-03 03:26:36 - Graham EllisDuring the final day of our "Learning to program in C" course - today - we built up an example that introduced structs, then added dynamic memory allocation so that we ended up with a flexible program capable of taking an unlimited amount of data. The build up examples also show (in the last program) reading of data from a file, tokenising a string, and extracting numbers from the various fields.
[link] to Simple demonstation of a structure
[link] to Copying Strings in and out of a structure
[link] to An Array of Structures
[link] to Structure Pointers
[link] to Dynamic allocation of memory for structs
[link] to Dynamic allocation for struct and struct pointers, and populating from file
[link] to Data for final example