I'm doing my school assignment and I've got issues with fscanf, file management so to speak. I've been at this for hours, looking up various functions and fscanf itself, and I'm still unable to solve this problem.
#include<stdio.h>
int main()
{
FILE *f3;
float amount_with[100][30];
int j;
char date_with[100][30];
f3 = fopen("withdrawals.txt", "r");
if (f3 == NULL)
{
printf("ERROR! File could not be opened.\n");
}
for(j=0; j <= 50 || !feof(f3); j++)
{
fscanf(f3, "%s %f", date_with[j], &amount_with[j]);
printf("%d %s RM %.2f", j+1, date_with[j], amount_with[j]);
}
}
I want to feed into the program a line of data of floats, integers and strings. (eg. 18/11/18 200.00 within this program) from a text file via fscanf, or any other possible way. However when I execute the code, the program hangs and I am unable to do anything within it other than CTRL+C.
Thanks for any help.