Reads a string from the input stream argument and stores it in string.
char * fgets( char * str, int nLen, FILE * stream )
It returns string. NULL is returned to indicate an error or an end-of-file condition. Use feof or ferror to determine whether an error occurred.
EX1
//The following example uses fgets to display a line from a file and then print out this line void test_fgets() { FILE *stream; char line[100]; stream = fopen( __FILE__, "r" ); if(stream != NULL ) { if( fgets( line, 100, stream ) == NULL) printf( "fgets error\n" ); else printf( "%s", line); fclose( stream ); } }
fgets reads a string from the input stream argument and stores it in string.
fgets reads characters from the current stream position to and including the first newline character, to the end of the stream, or until the number of characters read is equal to n-1, whichever comes first. The result stored in string is appended with a null character. The newline character, if read, is included in the string.
fputs
origin.h