Rule of precedence == over =

Posted by robUK on Stack Overflow See other posts from Stack Overflow or by robUK
Published on 2010-04-29T02:54:06Z Indexed on 2010/04/29 3:07 UTC
Read the original article Hit count: 140

Filed under:

Hello,

I am just wondering would it be better to do this:

if((fd = open(filename, O_RDWR)) == -1)
{
fprintf(stderr, "open [ %s ]\n", strerror(errno));

return 1;
}

or this

fd = open(filename, O_RDWR);
if(fd == -1)
{
    fprintf(stderr, "open [ %s ]\n", strerror(errno));

    return 1;
}

Many thanks for any suggestions,

© Stack Overflow or respective owner

Related posts about c