Some example C files:

These files end in .c.txt rather than .c, since some browsers will not display .c files as plain text. If you want to download, compile, and run them, remove the .txt extension after downloading.

A program with an array, a loop, and a sub-function... A program with 2 source files & a header file that illustrates pass-by-value and the use of pointers to implement pass-by-reference... A program with a struct that illustrates the syntax for dereferencing members of a structure and members of a structure via a structure pointer. Program that demonstrate using fgets to read a string from the standard input. The first program reads a single string of characters and prints the decimal and octal representations for the ASCII value of each character read in. The second reads in multiple lines and prints the number of numeric characters (0-9) on each line. The third reads in multiple lines and echos them back with their line number and the length of the line.