I am using an fscanf to read a sequence of 8 values of zero or one at the end of the line, but it looks like the array is never having a value read to it.
It is reading this from the text file:
Chilli Con Carne,Chilli_Con_Carne.txt, 15, 25, 100,0,0,0,0,0,0,0,0
Spaghetti Bolognese,Spaghetti_Bolognese.txt, 30, 75, 150, 0, 0, 0, 0, 0, 0, 1, 0
Frittata,Frittata.txt, 10, 15, 160, 1, 1, 0, 0, 0, 0, 0, 0
Korean Beef,Korean_Beef.txt, 20, 30, 100, 0, 0, 0, 0, 0, 1, 0, 1
Trawlers Pie, Trawlers_Pie.txt, 20, 30, 100,1,1,0,1,0,0,0,0
This is the loop I am using which contains the fscanf that is not reading the recipeAllergies:
while (!feof (cookBook)){
fscanf(cookBook, "%20[^,], %20[^,], %d, %d, %d", recipeName, recipeFileName, &prepTime, &cookTime, &calories);
printf("%s ", recipeName);
for (i = 0; i < 8; i++){
fscanf(cookBook, "%d,", &recipeAllergies[i]);
printf("%d %d\n", recipeAllergies[i], userAllergies[i]);
if ((userAllergies[i] + recipeAllergies[i]) == 2){
notSuitable = 1;
}
}
fgets(ignore_line, sizeof(ignore_line), cookBook);
if (notSuitable == 0){
(suitableRecipes[totalSuitable]. recipeName, recipeFileName, prepTime, cookTime, calories);
totalSuitable++;
}
}
Any help is greatly appreciated.