Click to See Complete Forum and Search --> : ! operator confusion


mmscg
April 12th, 2007, 08:02 AM
MSDN says if DeviceIoControl completes successfully, the return value is non zero.

Given this code:

if(!DeviceIoControl(<parameters>)
{
<code>
}
Is this the same thing?

BOOL bSuccess;

bSuccess = DeviceIoControl(<parameters>)
if(bSuccess == 0) //function call failed
{
<code>
}
(I know this is very basic, but the ! operator always causes me great confusion,
especially when some functions succeed return is zero, and others is non-zero.)

nitin1979
April 12th, 2007, 08:07 AM
BOOL bSuccess;

bSuccess = DeviceIoControl(<parameters>)
if(bSuccess == 0) //function call failed
{
<code>
}


this is only true when u have return type of function DeviceIoControl is BOOL

mmscg
April 12th, 2007, 08:12 AM
... but you are saying for DeviceIoControl specifically, my interpretation/code is correct?

nitin1979
April 12th, 2007, 08:13 AM
then it is same

mmscg
April 12th, 2007, 08:15 AM
Thanks!