I have a txt file which has the following input.
13
.34
67
45
12
4
85
56
42
44
2
8
3
5
2
the first number is the size, second is a multiplier, last one is used for search. I am wondering if the code below looks correct. The input text file name is "input.txt" or if there is a better way of collected the data and storing them for later use?
int main(int argc, char * argv[]){
int p;
double alpha;
int A[12];
int s;
if (argc<2){
printf("Error: include the name of the input file as an argument\n");
return 0;
}
printf("Attempting to open file %s\n",argv[1]);
FILE * F = fopen(argv[1],"input.txt");
printf("The file is now open for reading\n");
printf("Attempting to read \n");
fscanf(F,"%d, %lf, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",&p &alpha, A[0],A[1],A[2],A[3],A[4],A[5],A[6],A[7],A[8],A[9],A[10],A[11], &s ); // this line will crash if the file doesn't exist
printf("Read number %d from the file\n",number);
fclose(F);
printf("The file is now closed\n");
return 0;
}