I\'m trying to read a line using the following code:
while(fscanf(f, \"%[^\\n\\r]s\", cLine) != EOF )
{
/* do something with cLine */
}
If you try while( fscanf( f, "%27[^\n\r]", cLine ) == 1 ) you might have a little more luck. The three changes from your original:
27 here as an example, and unfortunately the scanf() family require the field width literally in the format string and can't use the * mechanism that the printf() can for passing the value ins in the format string - %[ is the format specifier for "all characters matching or not matching a set", and the set is terminated by a ] on its ownThat said, you'll get the same result with less pain by using fgets() to read in as much of a line as will fit in your buffer.