Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Question about "!".

Question about "!".

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    esepich
    wrote on last edited by
    #1

    With regards to: ---> bReadible = !(nStatus == 0); What does this mean? I have never seen code written like this before. BOOL CRawPingDlg::IsSocketReadible(SOCKET socket, DWORD dwTimeout, BOOL& bReadible) { timeval timeout; timeout.tv_sec = dwTimeout / 1000; timeout.tv_usec = (dwTimeout % 1000) * 1000; fd_set fds; FD_ZERO(&fds); FD_SET(socket, &fds); int nStatus = select(0, &fds, NULL, NULL, &timeout); if (nStatus == SOCKET_ERROR) return FALSE; else { bReadible = !(nStatus == 0); return TRUE; } } Thank you

    W D 2 Replies Last reply
    0
    • E esepich

      With regards to: ---> bReadible = !(nStatus == 0); What does this mean? I have never seen code written like this before. BOOL CRawPingDlg::IsSocketReadible(SOCKET socket, DWORD dwTimeout, BOOL& bReadible) { timeval timeout; timeout.tv_sec = dwTimeout / 1000; timeout.tv_usec = (dwTimeout % 1000) * 1000; fd_set fds; FD_ZERO(&fds); FD_SET(socket, &fds); int nStatus = select(0, &fds, NULL, NULL, &timeout); if (nStatus == SOCKET_ERROR) return FALSE; else { bReadible = !(nStatus == 0); return TRUE; } } Thank you

      W Offline
      W Offline
      W Hammer sledge
      wrote on last edited by
      #2

      The ! means NOT. If you have a boolean value like true the operator ! will make it to false. if nStatus has the value zero, the term wil be true. !(nStatus == 0) will make it false. It is the same if you write nStatus != 0. sledge

      1 Reply Last reply
      0
      • E esepich

        With regards to: ---> bReadible = !(nStatus == 0); What does this mean? I have never seen code written like this before. BOOL CRawPingDlg::IsSocketReadible(SOCKET socket, DWORD dwTimeout, BOOL& bReadible) { timeval timeout; timeout.tv_sec = dwTimeout / 1000; timeout.tv_usec = (dwTimeout % 1000) * 1000; fd_set fds; FD_ZERO(&fds); FD_SET(socket, &fds); int nStatus = select(0, &fds, NULL, NULL, &timeout); if (nStatus == SOCKET_ERROR) return FALSE; else { bReadible = !(nStatus == 0); return TRUE; } } Thank you

        D Offline
        D Offline
        DougW48
        wrote on last edited by
        #3

        esepich wrote: bReadible = !(nStatus == 0); What does this mean? I have never seen code written like this before. The ! negates the statement. if (nStatus == 0) is TRUE, then the ! negates it and bReadible will be FALSE. Douglas A. Wright dawrigh3@kent.edu

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups