Code:
char *fgets( char *str, int n, FILE *file );
fgets does the same thing gets does but better, because you passed a length argument. It accesses it's file argument, grabs n characters, stores them in str and returns str, or NULL if there was an error or EOF was encountered.
Saving files has nothing to do with it really.
There was an example in the faq but I guess another doesn't hurt. For example
Code:
#include <stdio.h>
int main( void ) {
char line[1024];
puts( "Enter some input and it will be echoed back." );
while ( fgets( line, sizeof line, stdin ) )
puts( line );
/** What happened when fgets returned NULL ? **/
if ( ferror( stdin ) )
perror( "stdin" );
else if ( feof( stdin ) )
puts( "No more input - bye!" );
return 0;
}
You'd only want to run this if you can redirect stdin or send EOF from your keyboard, or something.