I have a text file that has 1 word followed by ~ 100 floating point numbers. Floating-point numbers are separated by a space, tab, or new line. This format is repeated several times in a text file.
For example, it looks like a text file:
one 0.00591 0.07272 -0.78274 ...
0.0673 ...
0.0897 ...
two 0.0654 ...
0.07843 ...
0.0873 ...
three ...
...
...
My question is how can I count the number of words in a file, I tried to use fscanf, but as soon as it reads the first word, after that I need to skip all the floats to the next word.
Any help would be greatly appreciated.
Thanks.
source
share