The content of txt file is:
item,coke,juice,beer
1, 12, 26, 17
2, 8, 18, 15
3, 25, 35, 20
i just need to read the integers, how can i ignore all the char?
Code:int item,coke,juice,beer;
infile = fopen("itemlist.txt", "r");
if (infile == NULL) {
printf("Fail to open itemlist.txt!\n");
getchar();
return -1;
}
fscanf(infile, "%d, %d, %d, %d", &item,&coke,&juice,&beer);
fflush(stdin);
fclose(infile);