I'm making quiz program in c and part of my program is to getting questions from text file, count and print them. But when i want to print or count them every time it sees whitespace it skips to other variable. How can i solve it?
That's my txt file
What is the Capital of France? Paris Roma London Istanbul Belgrad
And how it seems in my program.
What
a)is
b)the
c)capital
d)of
e)France
That's how i get questions
FILE *fp = fopen("fp.txt", "a+");
gets(questions[n].question_part);
gets(questions[n].a);
gets(questions[n].b);
gets(questions[n].c);
gets(questions[n].d);
gets(questions[n].e);
questions[n].answer=getch();
fprintf(fp, "%s %s %s %s %s %s %c", questions[n].question_part, questions[n].a, questions[n].b, questions[n].c, questions[n].d, questions[n].e, questions[n].answer);
n++;
How i count
int x=0;
while(!feof(fp)){
fscanf(fp, "%s %s %s %s %s %s %c", questions[x].question_part, questions[x].a, questions[x].b, questions[x].c, questions[x].d, questions[x].e, questions[x].answer);
x++;}
n=x;
And how i print
FILE *fp;
fp = fopen("fp.txt", "r");
int y;
for(y=0;y<n;y++)
{
printf("\nQuestion number %d:\n",y+1);
printf("Question: %s\n",questions[y].question_part);
printf("a)%s\n",questions[y].a);
printf("b)%s\n",questions[y].b);
printf("c)%s\n",questions[y].c);
printf("d)%s\n",questions[y].d);
printf("e)%s\n",questions[y].e);
printf("Answer: %c\n",questions[y].answer);
}