If we want to read a whole line in the file then each time we will need to call character input function, instead C provides some string input/output functions with the help of which we can read/write a set of characters at one time. These are defined in the standard library and are discussed below:
• fgets( )
• fputs( )
These functions are used to read and write strings. Their syntax is:
int fputs(char *str, FILE *stream);
char *fgets(char *str, int num, FILE *stream);
The integer parameter in fgets( ) is used to indicate that at most num-1 characters are
to be read, terminating at end-of-file or end-of-line. The end-of-line character will be
placed in the string str before the string terminator, if it is read. If end-of-file is
encountered as the first character, EOF is returned, otherwise str is returned. The
fputs( ) function returns a non-negative number or EOF if unsuccessful.
0 टिप्पणियाँ:
Post a Comment