I am trying to get one whole line from some text file instead of one word until it meets white space, here is source code:
#include <stdio.h>
void main() {
int lineNum=0;
char lineContent[100];
scanf("%s", &lineContent);
printf("%s\n", lineContent);
}
And here is my text file, called test.txt, content containing 2 lines:
111 John Smith 100 98 1.2 2.5 3.6
222 Bob Smith 90 91 3.2 6.5 9.6
And I run it with following command:
a.out < test.txt
My output is just:
111
What I want is:
111 John Smith 100 98 1.2 2.5 3.6
Of course, I can simply use while statement and read recursively until it meets EOF, but that is not what I want. I just want to read one whole line per each time I read from file.
How can I do this?
Thank you very much.