Writing File or fputc() function
The fputc() function is used to write a single character into file. It outputs a character to a stream.putc() function is C library function, and it's used to write a character to the file.
This function is used for writing a single character in a stream along with that it moves forward the indicator's position.
Syntax: fputc(int c, FILE *stream)
Example:-
Reading File : fgetc() function
The fgetc() function returns a single character from the file. It gets a character from the stream. It returns EOF at the end of file.getc() function is C library function, and it's used to read a character from a file that has been opened in read mode by fopen() function.
* getc() function returns next requested object from the stream on success.
* Character values are returned as an unsigned char cast to an int or EOF on end of file or error.
* The function feof() and ferror() to distinguish between end-of-file and error must be used.
Syntax: fgetc(FILE *stream)
Example:-
Comments
Post a Comment