Possible Duplicate:
Logical comparisons: Is left-to-right evaluation guaranteed?
I have been taught that for every C function arguments, Rightmost argument will be executed/processed first and it progresses towards left. Right part will be executed first and it progresses towards left.
Is this applicable to conditions like && and || ??
If I am writing a C++ Code, I check for NULL condtion first and then in next if I perform my action. for e.g.
if( CommDevice != NULL)
{
if(CommDevice->isOpen == TRUE)
{
//Do Something
}
}
Can I convert this in if((CommDevice != NULL) && (CommDevice->isOpen == TRUE) )
That "Code executes from Right to Left" fear is stopping me coz what if CommDevice
is NULL and I am trying to access a member of NULL. It will generate exception.