The information in this article applies to:
SYMPTOMSWhen a file is open in text mode, an attempt to read lines of text with the fscanf() function may fail and only one line of text is read from the file. CAUSEThe delimeter is set to "[^\n]". The fscanf() function reads up to but does not include the delimiting character. Therefore, the file stream stops at the first '\n' in the file. Subsequent fscanf() calls fail because the file pointer remains at the delimiting character and fscanf() cannot advance the function pointer past it. RESOLUTIONUse one of the following two methods to move the file pointer past the delimiting character:
MORE INFORMATIONThe following code demonstrates this problem. It should read and print lines from a text file until it reaches EOF. However, it reads only the first line from the file. Since the end of file character has not been found, the example shown below will run in an infinite loop if the file stream contains a "\n" character. Sample Code
The following code demonstrates the second method above to work around
this problem:
Additional query words: 8.0 9.0 10.0 11.0
Keywords : kbcode kbCRT kbVC kbVC100 kbVC150 kbVC200 kbVC210 kbVC400 kbVC410 kbVC420 kbVC500 kbVC600 |
Last Reviewed: February 2, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |