Reading Data From Command Line
#include <stdio.h>
#include <conio.h>
int argc; /* argument count */
char *argv[]; /* list of arguments */
{
FILE *fp;
int i;
fp = fopen(argv[1], "w"); /* open file with name argv[1] */
printf("\nNo. of arguments in Command line = %d\n\n",argc);
for(i = 2; i < argc; i++)
fprintf(fp,"%s ", argv[i]); /* write to file argv[1] */
fclose(fp);
getch();
}
}
No comments:
Post a Comment