C Program crashes after last scanf/last loop, (trivia game).
struct myQuiz*quizInput(int *nrQ)
{
int i, nrofrecords = 0;
struct myQuiz *Quiz = (struct myQuiz*)malloc(sizeof (struct myQuiz)**nrQ);
printf("How many Questions?\n");
scanf_s("%d", nrQ);
for (i = 0; i < *nrQ; i++) //for-loop för att skriva in påståenden
{
printf("Trivia input: ");
fflush(stdin);
fgets(Quiz[i].qQuest, 100, stdin);
nrofrecords = nrofrecords + 1;
fflush(stdin);
printf("Enter answer '1'(yes) or '0' (no): ");
scanf_s("%d", &Quiz[i].qAns);
fflush(stdin);
printf("Enter the difficulty (1-5)?: ");
scanf_s("%d", &Quiz[i].qDiff);
}
return Quiz;
}