I am wanting to write a program in c that takes in an integer, an input file and an output file when compiled. The execution code should be as follows:
./example N input_file output_file
I'm trying to work out how to configure this in c. So far I have managed to successfully take in the input_file and output_file and code is as follows:
int main(int argc, char *argv[]){
FILE *M, *fin, *fout;
int *N;
// check if we have 3 arguments - remember that the first one is the file name
if(argc!=4){
printf("ERROR: not enough input parameters\n");
printf("USE: %s input output\n",argv[0]);
exit(1);
}
N = argv[1];
printf("%f \n",DECIMATION_FACTOR);
// open input files as binary read-only
fin=fopen(argv[2],"rb");
if(fin == NULL) {
printf("ERROR: %s does not exist\n",argv[1]);
exit(1);
}
// open output files as binary - overwrite the file if it alredy exists
fout=fopen(argv[3],"w+b");
if(fout == NULL) {
printf("ERROR: %s cannot be created\n",argv[2]);
exit(1);
}
}
How can I input an integer where N is?