I have a .txt
file as:
A B C
England vs autralia
2004
100
D E F
japan vs argentina
3045
140
D E F
india vs pakistan
2012
150
J F G
south africa vs india
1967
100
K GHD D
australia vs pakistan
1993
453
Z E Q
pakistan vs england
2013
150
I want to read it and store in variables. (each line goes to a single variable).
I have this code but it read's one line at a time and as a string.
if ( file != NULL )
{
i=1;
char line [ 100 ]; /* line size */
while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{
fputs ( line, stdout ); /* write the line */
i++;
}
fclose ( file );
}
Actually I want to read 4 lines at a time. but seems impossible. So I can put the 4 line in a single line separated by a space but in that case scanning multi-word strings will not be possible.
So,How do I do this?