C Programming

INPUTTING/OUTPUTTING SINGLE CHARACTERS
Single characters may be read/written with files by use of the two functions, getc(), and putc().


	int ch;

	ch = getc( input_file );   /*  assigns character to ch  */

The getc() also returns the value EOF (end of file), so


	while( (ch = getc( input_file )) != EOF )
		......................

NOTE that the putc/getc are similar to getchar/putchar except that arguments are supplied specifying the I/O device.


	putc('\n', output_file ); /* writes a newline to output file */


©Copyright B Brown. 1984-1999. All rights reserved.