I say that it must be this function because it stops right after I enter an int and it doesn't read the print statement.
recipe** readAllRecipes(int numRecipes)
{
recipe** theRecipes = malloc(sizeof(recipe *) * numRecipes);
int i;
for(i = 0; i < numRecipes; i )
{
scanf("%d", &theRecipes[i]->numItems);
printf("\n\n\t\t here in readAll for loop\n");
theRecipes[i] = readRecipe(theRecipes[i]->numItems);
}
return theRecipes;
}
CodePudding user response:
Here's the problem:
scanf("%d", &theRecipes[i]->numItems);
theRecipise[i]
is not initalized and you dereference it. Should allocate it first:
theRecipes[i] = malloc(sizeof(recipe));
scanf("%d", &theRecipes[i]->numItems);
but lower down I'm baffled by this:
theRecipes[i] = readRecipe(theRecipes[i]->numItems);