char * fgets (char * string , int num , FILE * stream);
Get a string from a stream.
Reads characters from stream and stores them in string until (num -1) characters have been read or a newline or EOF character is reached, whichever comes first.
A newline character ends reading but is considered a valid character and included in the new string.
A null character is always appended at the end of the resulting string.
On success, the string read is returned.
On end-of-file or error, null pointer is returned. Use ferror or feof to check what happend
/* fgets exmaple */
FILE * pFile;
char string ;
pFile = fopen ("myfile.txt" , "r");
if (pFile == NULL) perror ("Error opening file");
fgets (string , 100 , pFile);
This example reads and prints out on the screen the first line of myfile.txt
or the first 100 characters, whichever comes first.
fputs, fgetc, gets, puts