/* Pro69.c */
/* How to read any filename? The simplest format by DOS command line. */
#include<stdio.h>
#include<string.h>
char inline[100];
main(int argc, char *argv[])
{
FILE *fp;
if (argc!=2){
printf("Usage: pro69.exe infile.txt > outfile.txt\n");
}
else
fp=fopen(argv[1], "r");
/* Explanation of if()-else loop above. */
/* argc counts arguments in the DOS command line from left. */
/* Right side of redirection is not counted. Thus this is argc=2, */
/* since (1) pro69.exe; (2) infile.txt. "!=" means Not Equal. */
/* Now, argv[0] is pro69.exe, argv[1] is infile.txt. Else is */
/* opening "infile.txt". If(argc!=2) is a cautious remark. */
while(fgets(inline, 100, fp)!=NULL){ /* Read infile.txt one line each time */
printf("%s", inline); /* Echo print out one line each time */
}
fclose(fp);
return 0;
}