Re: REMINDER: Do not use your real email adddress

From: Baho Utot (baho-utot_at_philippines-island.org)
Date: 09/25/03


Date: Thu, 25 Sep 2003 20:00:40 GMT

Mark A. Odell wrote:

>
>
> Joe Beanfish <joebeanfish@nospam.duh> wrote in
> news:3F73226C.CACAD4B6@nospam.duh:
>
>> No. fgets() returns a pointer, not a char or int.
>> Comparing it to '\0' will work in many circumstances
>> if the compiler doesn't reject it, but it's not a good idea.
>> It should be
>>
>> if(fgets(email, E_BUFFER, stdin) == NULL) {
>
> C's notion of a boolean is guaranteed to work just as well I believe. E.g.
>
> if(!fgets(email, E_BUFFER, stdin))
>

Yes, I concur. But if your really paranoid then

if((char*)0 == fgets(email, E_BUFFER, stdin)) {
        .......... some code
}

I always test as above because if you have a brain fart and do:

if((char*)0 = fgets(email, E_BUFFER, stdin)) {
        .......... some code
}

Then the compiler will complain you can not assign to a constant (or
something like that, I don't recall exactly).

Later Dudes



Relevant Pages

  • Re: Replacing fgets
    ... Even if u_int8_t is a typedef for unsigned char, ... Didn't your compiler complain here. ... offset is changed ... offset needs to be an int. ...
    (comp.lang.c)
  • Re: How to use a C++ class in .NET
    ... > absolutely compiler dependant. ... > public ref class MyClass ... > int funtion1(unsigned char* inBuffer, unsigned inType, unsigned char* ...
    (microsoft.public.dotnet.framework)
  • Re: How to use a C++ class in .NET
    ... absolutely compiler dependant. ... public ref class MyClass ... int funtion1(unsigned char* inBuffer, unsigned inType, unsigned char* ...
    (microsoft.public.dotnet.framework)
  • Re: querry related to structure padding
    ... char B; ... The compiler is still free to insert padding between B and C, ...
    (comp.lang.c)
  • Re: Error in Passing char pointer
    ... int main ... Always ensure that the compiler sees a prototype for each function before calling it. ... Why is ea unsigned char when everything else is signed char? ... Also your pointer types disagree with the pointers you are passing, unsigned char* and char* are not the same. ...
    (comp.lang.c)