#include /* files1.c 1/24/96 1. Create a file called mongoose.txt (or pick a different name and change the fileName[] initialization below) containing a few lines of text. You can, of course, do this with an editor. A handy technique for making small test files without leaving your Unix window is this: prompt> cat > mongoose.txt These are some words in my test file. Yipee. prompt> You can check to see whether "cat" (which stands for "concatenate") made your new file properly by typing "cat mongoose.txt" or "more mongoose.txt". To add some stuff to the end of an existing file, you can do this: prompt> cat >> mongoose.txt New stuff for the end. prompt> Try it out. If you're curious about "cat", "man cat" is always available to you. 2. Compile and run this program. Why did I put at-signs in the output? 3. When you use fscanf(), does "%s" match the whole rest of the current line of text, or does it match only the next word? Does "%s" discard initial white space, or does it include spaces and tabs in the string it gives you? What if you try to match "%s" and the current line is a blank line--does fscanf() read past the newline character in search of a string? */ void main() { FILE *theFile; char fileName[20] = "mongoose.txt"; char str[100]; theFile = fopen( fileName, "r" ); if( theFile == NULL ) { fprintf( stderr, "Can't open %s for reading.\n", fileName ); exit( 1 ); } fscanf( theFile, "%s", str ); fprintf( stdout, "The string is @%s@.\n", str ); fclose( theFile ); }