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. Check for input from console in C++

Check for input from console in C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadmincollaborationquestion
3 Posts 2 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.
  • D Offline
    D Offline
    dabs
    wrote on last edited by
    #1

    Hi, I have a loop in a C++ program which is constantly checking for input from a network source, but I also want to check if the user has entered something into the console - such as a command to stop the program. Obviously I cannot use just standard cin << strCommand;, since that would block until something is entered. Is there any way for me to check if the console has received input? Regards, Daníel


    Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

    N 1 Reply Last reply
    0
    • D dabs

      Hi, I have a loop in a C++ program which is constantly checking for input from a network source, but I also want to check if the user has entered something into the console - such as a command to stop the program. Obviously I cannot use just standard cin << strCommand;, since that would block until something is entered. Is there any way for me to check if the console has received input? Regards, Daníel


      Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      you can use the _kbhit() function. This function returns a nonzero value if a key has been pressed.

      D 1 Reply Last reply
      0
      • N Naveen

        you can use the _kbhit() function. This function returns a nonzero value if a key has been pressed.

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

        Thanks, exactly what I need! Regards, Daníel


        Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

        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