#include #include int main() { char * ptr; char str[80]; FILE * fp; fp = fopen ( "foo.txt", "rw+" ); fprintf ( fp, "hello world\n" ); fclose( fp ); fp = fopen ( "foo.txt", "rw+" ); fgets ( str, 80, fp ); fclose( fp ); fprintf ( stdout, "this string is '%s'\n", str ); /* remove the \n */ if ( ( ptr = strchr ( str, '\n' ) ) ) { *ptr = 0; } fprintf ( stdout, "this new string is '%s'\n", str ); return 0; }