Re: EOF question...

From: Michael Mair (Michael.Mair_at_invalid.invalid)
Date: 02/04/05


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.


Relevant Pages

  • Re: Simple Form Validation
    ... Don't rely on luck. ... Strings are compared as strings, and can be converted to numbers with ... Specifying absolute sizes is in breach of disabled access legislation ... Read the newsgroup FAQ again. ...
    (comp.lang.javascript)
  • Re: !! IMPORTANT !! New ColecoVision FAQ released, version 4.0
    ... to eye the valuable desktop space. ... Is there a newsgroup or other group for Coleco owners? ... And I've looked over the faq, ... "luck out", with no luck. ...
    (rec.games.video.classic)
  • Re: Checking in
    ... two more newbies just like me. ... Good luck in your smobriety and ... know that you are not alone. ...
    (alt.support.stop-smoking)
  • Re: timesheets pending approval
    ... Try posting on the server newsgroup as this one is closing down. ... FAQ Item: 24. ... When I query the database for timesheets pending approval, ... I've tried re-publishing the plan with no luck. ...
    (microsoft.public.project.pro_and_server)
  • Re: problem with function
    ... mobile Cephus wrote: ... The program below seems to work, because you had a case of bad luck. ... Here you let newName refer to the same memory location as oldName. ... a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq ...
    (alt.comp.lang.learn.c-cpp)