#include /* args2.c 1/24/96 1. This program shows you a typical way of handling command-line arguments. Run this program with various combinations of command-line arguments--none, one, two, etc. Try it with one argument using the name of an existing text file, and then try it with one argument using a non-existent file name. 2. What happens if you remove the "if( argc != 2 )" test and you run the program with no arguments? Is it the same on the white and black NeXTs? */ void main( int argc, char *argv[] ) { char str[100]; FILE *theFile; if( argc != 2 ) { fprintf( stderr, "Usage: %s fileName\n", argv[0] ); exit( 1 ); } theFile = fopen( argv[1], "r" ); if( theFile == NULL ) { fprintf( stderr, "Can't open %s for reading.\n", argv[1] ); exit( 1 ); } fscanf( theFile, "%s", str ); fprintf( stdout, "The string is @%s@.\n", str ); fclose( theFile ); }