/* catprocfile.c * Neal Nelson * * Just copy the specified proc file to stdout in 80 character blocks until EOF */ #include #include #define MAXLINE 80 main(int argc, char *argv[]) { char buf[MAXLINE+1]; /* room for the string terminator zero */ FILE *fp; if (argc != 2) { printf("usage: catprocfile procfile\n"); exit(1); } if ( (fp = fopen(argv[1],"r")) == NULL) { printf( "No file named: %s\n",argv[1] ); exit(1); } /* fgets reads one less than specified number of characters and adds zero*/ while (fgets(buf, MAXLINE+1, fp) != NULL ) { printf("%s",buf); } exit(0); }