Originally Posted by
vart
your solution is good for the space separated words
in your case you have strings separated by ;
the noted thread has examples how to parse such type of strings. Have you read all the thread?
Yes vart i did,
when i compile i get these errors:
Code:
In function `void spelen()':
expected primary-expression before '.' token
expected primary-expression before '.' token
expected primary-expression before '.' token
expected primary-expression before '.' token
expected primary-expression before '.' token
expected `;' before '}' token
and i changed my code to this after reading the thread you suggested me;
Code:
{
static const char filename[] = "vragen.txt"; /* the name of a file to open */
FILE *file = fopen(filename, "r+"); /* try to open the file */
if ( file )
{
char line[BUFSIZ]; /* space to read a line into */
int k = 0;
while ( fgets(line, sizeof line, file) ) /* read each line */
{
sscanf(line, "%[^ ]%[^;];%[^;];%[^;]",
vragen.vraag,
vragen.antw,
vragen.antw1,
vragen.keuze);
}
fclose(file);
}