This program is intended to read a .txt file to get a set of numbers, and write to another two .txt files called even and odd as follows:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i=0,even,odd;
int number[i];
// check to make sure that all the file names are entered
if (argc != 3) {
printf("Usage: executable in_file output_file\n");
exit(0);
}
FILE *dog = fopen(argv[1], "r");
FILE *feven= fopen(argv[2], "w");
FILE *fodd= fopen (argv[3], "w");
// check whether the file has been opened successfully
if (dog == NULL)
{ printf("File %s cannot open!\n", argv[1]);
exit(0);
}
{ if
(i%2!=1)
i++;}
fprintf(feven, "%d", even);
fscanf(dog, "%d", &number[i]);
else {
i%2==1;
i++;}
fprintf(fodd, "%d", odd);
fscanf(dog, "%d", &number[i]);
fclose(feven);
fclose(fodd);
}