Have a problem with fscanf() – it does not skip to the next word after reading 10 characters from the file
while(fscanf(TEXT_FILE,"%10s", str) != EOF) // reads up to 10 char into str
If it find the word that is greater than 10 characters, it will read 10 characters, store them into str, continue in the same word reading up to 10 characters.
How would I specify to read up to 10 char and skip to the next word ?
Is there an alternative ?
Thanks !
I’ve found a solution for you:
It works on VS 2008. I’m not sure if it is standard or not, and if your compiler will support it or not. The
%*spart will skip current string (if it is having length greater than 10) upto next whitespace character and will consume all whitespace characters.