@citizen: thanks for the tip! i've changed this to
Code:
#define MAXVRAAG 30
#define VRAGEN_COUNT MAXVRAAG
like you said.
But, i've encountered another problem; i can't seem to compare the user input with a member of the array. When i run the program, it's always "Incorrect!".
included my code;
Code:
{
struct vragen quiz[100];
int i;
static const char filename[] = "vragen.txt"; /* the name of a file to open */
char antwoord[2];
FILE *file = fopen(filename, "r+"); /* try to open the file */
if ( file )
{
char line[BUFSIZ]; /* space to read a line into */
int i = 0;
while ( fgets(line, sizeof line, file) ) /* read each line */
{
sscanf(line, "%[^;];%[^;];%[^;];%[^;]",
quiz[i].vraag,
quiz[i].antw,
quiz[i].antw1,
quiz[i].keuze);
i++;
if(i == VRAGEN_COUNT) break;
}
fclose(file);
}
for(i ; i < VRAGEN_COUNT; i++)
{
printf("%s \n\nA: %s \nB: %s\n", quiz[i].vraag, quiz[i].antw, quiz[i].antw1);
scanf("%s", antwoord);
if(antwoord == quiz[i].keuze)
{
printf("Correct!\n");
}
else printf("Incorrect!\n");
}
}