1 2 3 4 5 6

The Standard I/O Library

*#include <stdio.h>
All I/O involves a stream, there are three standard streams that are defined in stdio.h
stdin- the standard input, for reading
stdout - the standard output, for writing
stderr - for error messages

You can declare a pointer to your own stream in the following way:
FILE* fp;

Use the fopen()procedure to attach a file for reading, writing or appending data.
FILE* fopen(char* FileName, char* AccessMode);

Themost popular access modes are:
"r" - a read-only file
"w" - write, starting at the front
"a" - write, appending to the end

*Thus we can open local file "tally.data" for reading with
the command
fp = fopen ("tally.data", "r");
*A value of NULL is returned if the file can't be opened Use fclose() to flush buffered data to the file

fclose(fp);

1 February, 1998

1

CopyrightUniversity of Alberta