Originally Posted by
Dave_Sinkula
And what is the size that buf is declared?
25
Code:
void main(int arcg, char *argv[])
{
char buf[25];
char file1[20] = " ";
char file2[20] = " ";
char a[20] = " ";
int b;
FILE *infile, *outfile;
if (arcg != 4) {printf("\cut [column] [file to scan] [file to write to]");
return;
}
strcpy(a, argv[1]);
strcpy(file1, argv[2]);
strcpy(file2, argv[3]);
b = atoi (a);
if ((infile = fopen(file1,"r")) == NULL)
{ printf("The file that you want\n");
printf("scanned is not found. Try again.");
return;
}
if ((outfile = fopen(file2,"w")) == NULL){ fclose(infile); return;}
while(fgets(buf, sizeof(buf), infile))
fprintf(outfile, "%.6s\n", buf + b);
}