#include <stdio.h> int main(int *argc, char *argv[]) { FILE *fp; short indx; char ch; for(indx=1; argv[indx] != 0; indx++) { printf("file -> %s\n", argv[indx]); if(!(fp = fopen(argv[indx], "r"))) { fprintf(stderr, "Error while trying " "to read file: %s\n", argv[indx]); return(1); } while((ch = getc(fp)) != EOF) putchar(ch); fclose(fp); putchar('\n'); } return(0); }
OUTPUT:
file -> 1FILENAME
CONTENT OF FILE 1
file -> 2FILENAME
...
Nenhum comentário:
Postar um comentário