/* Program FILE_1.C
**
** Illustrates how to write to a file. This opens up the possibility
** for data logging.
**
** copyright,Peter H. Anderson, Baltimore, MD, Sept, '00
*/
#include <stdio.h>
FILE *f1;
void main(void)
{
int n;
f1 = fopen("test.txt", "wt"); /* open the file */
for (n=0; n<10; n++) /* generate some numbers */
{
printf("%d\n", n);
fprintf(f1, "%d\n", n); /* write to the file */
}
fclose(f1); /* close the file */
}