-
-
Save karno/642202 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
void ReadFile(char* fname) | |
{ | |
FILE *fp; | |
char buf[1024]; | |
if ((fp = fopen(fname, "r")) == NULL) | |
{ | |
fprintf(stderr, "File not found:%s\n", fname); | |
return; | |
} | |
printf ("\n\nFile:%s\n\n", fname); | |
int cnt = 1; | |
while (fgets(buf, 256, fp) != NULL) | |
{ | |
printf("%3d: >> %s", cnt, buf); | |
cnt++; | |
} | |
fclose(fp); | |
} | |
int main(int argc, char* argv[]) | |
{ | |
if (argc < 2) | |
{ | |
fprintf(stderr, "No argument!"); | |
exit(-1); | |
} | |
else | |
{ | |
int i = 1; | |
for (i = 1; i < argc; i++) | |
{ | |
ReadFile(argv[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment