strange issue reading /dev/null

Sean C. Farley scf at FreeBSD.org
Thu Aug 7 16:54:13 UTC 2008


On Thu, 7 Aug 2008, Gabor Kovesdan wrote:

> Sean C. Farley ha scritto:
>> You are testing c which has not been set.  It works OK if you set c
>> then do the test:
>> 
>> +       c = fgetc(f);
>>         if (c != EOF)
>> -               printf("%c\n", fgetc(f));
>> +               printf("%c\n", c);
> Yes, you are right, this is what I meant, I'm just a bit
> disorganised....
> Thanks!

You are welcome.

Actually, what I found odd was that the base gcc did not warn about
using an uninitialized variable using -Wall.

Obviously, test fopen() and fgetc() return codes correctly as others
have noted.  I just assume you were not in your test program.

Sean
-- 
scf at FreeBSD.org


More information about the freebsd-hackers mailing list