Sequential Files (Ch. 28)

Specimen code and executable from Winter 2014:  fileStuff.txt   fileStuff.c   fileStuff.exe
Data file:  NumIn.txt

Specimen code and executable from Winter 2014:  fileStuff2.txt   fileStuff2.c   fileStuff2.exe
Since this generates a copy of an arbitrary text file, it does not have a specialized data file.

Specimen code and executable from Winter 2014:  dynamicArrays.txt   dynamicArrays.c   dynamicArrays.exe
Data file:  NumIn2.txt

Application writing information to a file:  the C program simulates the "drunkard's walk" or a random walk.  (Wikipedia page on the random walk.)  Each step is taken in a random direction.  The current location is written to the output file in the format of a "comma-separated value" file (CSV):  two numbers to a line, separated by a comma.  The traversal continues until the current location moves out of range.  A blank line is added at the end, in case the user wishes to save multiple runs.  For this to be available, the output file must be opened for append ("a") and not for write ("w").

Motion constrained to horizontal, vertical, and diagonal.  The Excel workbook showing one run is also included, as well as a traversal plot.
Drunk.txt   Drunk.c   Drunk.exe   Drunk.xls   Drunk.jpg

Motion consists of unit steps in completely random directions:
RandWalk.txt   RandWalk.c   RandWalk.exe   RandWalk.xls   RandWalk.jpg

Enrichment material:
Example:  Generating an output file that can go into a spreadsheet to graph some quantity of interest.  In this case, as N increases, what is the density of prime numbers as a function of N.
PrimeDensity.txt   PrimeDensity.c   PrimeDensity.exe   PrimeDensity.jpg   PrimeDensity.xls