Re: EOF question...
From: Michael Mair (Michael.Mair_at_invalid.invalid)
Date: 02/04/05
- Next message: CBFalconer: "Re: realloc() question"
- Previous message: No Such Luck: "Re: EOF question..."
- In reply to: No Such Luck: "Re: EOF question..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 04 Feb 2005 00:14:06 +0100
No Such Luck wrote:
>>Check again. Question 12.2 tells you how to correctly use feof() --
>>which is essentially to leave it alone and use the value returned
>>by the functions to read through the file.
>>Checking the FAQ tells you also to (always) check the return value of
>>*scanf() which would also helped you
>>
>>See Jerry's suggestion.
>>
>>while (fscanf(file, "%s", string) == 1)
>>{
>> if (!strcmp (string, "Error:"));
>> {
>> error = 1;
>> break;
>> }
>>}
>>
>>Think about using fgets() or using fscanf() in a safer way, i.e.
>>without the possibility for an overflow of string.
>
>
> Thanks for the help. comp.lang.c to the rescue, again.
>
> P.S. Thanks for the semi-colon after the "if" statement. That cost me
> about 15 minutes... ;)
*g* Sorry, I just copied _your_ code... and did (shame on me)
oversee it. Makes you richer in experience.
BTW: splint and Co. can warn about things like this and high
enough warning levels of a good compiler might do so as
well... :-)
Cheers
Michael
-- E-Mail: Mine is an /at/ gmx /dot/ de address.
- Next message: CBFalconer: "Re: realloc() question"
- Previous message: No Such Luck: "Re: EOF question..."
- In reply to: No Such Luck: "Re: EOF question..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|