1 #include <stdio.h> 2 #include <stdlib.h> 3 output(char * filename)4int output(char * filename) 5 { 6 FILE * fp; 7 char str[64]; 8 9 if((fp = fopen(filename, "r")) == NULL) { 10 printf("Cannot open file %s.\n", filename); 11 return 1; 12 } 13 14 while(!feof(fp)) { 15 if(fgets(str, 128, fp)) { 16 printf("%s", str); 17 } 18 } 19 20 fclose(fp); 21 return 0; 22 } 23 24 25 26 main(int argc,char ** argv)27int main(int argc, char ** argv) 28 { 29 if(argc < 2) 30 { 31 printf("Syntax: %s <input file>\n", argv[0]); 32 exit(1); 33 } 34 return output(argv[1]); 35 } 36 37