CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    204

    ! operator confusion

    MSDN says if DeviceIoControl completes successfully, the return value is non zero.

    Given this code:
    Code:
    if(!DeviceIoControl(<parameters>)
    {
        <code>
    }
    Is this the same thing?
    Code:
    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.)

  2. #2
    Join Date
    Feb 2007
    Posts
    141

    Re: ! operator confusion

    Code:
    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

  3. #3
    Join Date
    Apr 2004
    Posts
    204

    Re: ! operator confusion

    ... but you are saying for DeviceIoControl specifically, my interpretation/code is correct?

  4. #4
    Join Date
    Feb 2007
    Posts
    141

    Re: ! operator confusion

    then it is same

  5. #5
    Join Date
    Apr 2004
    Posts
    204

    Re: ! operator confusion

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured