Академический Документы
Профессиональный Документы
Культура Документы
Introduction
Part of any useful computer program is often going to be manipulation of external data sources. The
file is the basic unit of storage for many operating systems, from Unix to Mac. Any C development
environment on these platforms will include functions allowing the programmer to:
Open & Close files;Read from & Write to files;Delete files.Commands for all of the above are found
in the stdio.h header file.Opening & Closing Files
The basic command used to open a file is:
however, that if it is not a pointer type (int *, char * etc.), then it will need to be passed by reference
(&nNumber, for example). This will create the appropriate cast to the variable being passed. So, to
read a number, we would use:
int nRead = fread(&nNumber, sizeof(int), 1, hFile);