C noob question here.
I'm going through step by step trying to make a function that will do calculations with each element in my array. My array needs to be filled with numbers it gets from a txt file. Before I go through building my function I just wanted to make sure my arrays were filling properly with my end file loop so I wrote the printf statement in my EOF loop.
Why is it that this loop only prints one thing at a time and makes me hit enter in order for it to get the next thing? Did it fill the cells of the array properly or is it only filling the cells everytime i hit enter?
int day, month, id, i=1;
FILE*infile = fopen("usage.txt", "r");
FILE*outfile = fopen("charges.txt", "w");
fscanf(infile, "%d %d", &day, &month);
printf("day: %d month: %d\n", day, month);
while ((c = getchar()) != EOF)
fscanf(infile, "%d %lf", &id, &hours_used);
id_array[i] = id;
charges_array[i] = hours_used;
printf("ID: %d hours used: %lf\n", id_array[i], charges_array[i]);