So my assignment is make a dynamic array to read integers from a file, which the first integer is the size used to create a dynamic array. But I am lost at how to specifically take the first integer.
main(int argc, char **argv) {
float average; /* SET this variable to computed average */
int small, second_small; /* and these hold the smallest values */
FILE *input_file;
char filename[32];
if ((argc == 2)&&(strcmp(argv[1],"-d")==0)) input_file = open_file();
else {
if (argc != 2) {printf("Usage: %s <filename>\n",argv[0]); exit(2);}
if ((input_file = fopen(argv[1],"r")) == NULL) {
printf("Unknown file: %s\n",argv[1]); exit(3);
}
}
I dont ask for code, I asking on how to handle the file. Thank you guys.