Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. why no response to my cin input ?
Forum Update on Monday, May 27th 2025

why no response to my cin input ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
5 Posts 5 Posters 2.7k Views
  • 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    Here is my FIRST usage of cout / cin using QT console.

    My code :

      char i;
        std::cout << " Hello...\n";
        std::cout << "Enter password: ";
        std::cin >> i;
        std::cout << "Password entered is " << i;
    

    and its output

    Hello...
    Enter password:q

    no response AFTER "q and enter key is pushed" - using debug console .

    What simple thing / setting am I missing ?

    There is a "Enter" key on keyboard I am pushing....

    S 1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      two things:

      1. insert std::flush after your "Enter Password" prompt
      2. make i an std::string

      As for now seeing output, you should see output only after flushing cout.

      JonBJ 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        two things:

        1. insert std::flush after your "Enter Password" prompt
        2. make i an std::string

        As for now seeing output, you should see output only after flushing cout.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Kent-Dorfman said in why no response to my cin input ?:

        insert std::flush after your "Enter Password" prompt

        @AnneRanch
        Actually, after std::cout << "Enter password: "; is not where you need your std::flush() or std::endl. Because that is followed by a std::cin >> i; it auto-flushes, as you see in the output you show. You need it after your std::cout << "Password entered is " << i;, e.g.

        std::cout << "Password entered is " << i << std::endl;
        
        1 Reply Last reply
        0
        • A Anonymous_Banned275

          Here is my FIRST usage of cout / cin using QT console.

          My code :

            char i;
              std::cout << " Hello...\n";
              std::cout << "Enter password: ";
              std::cin >> i;
              std::cout << "Password entered is " << i;
          

          and its output

          Hello...
          Enter password:q

          no response AFTER "q and enter key is pushed" - using debug console .

          What simple thing / setting am I missing ?

          There is a "Enter" key on keyboard I am pushing....

          S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          @AnneRanch said in why no response to my cin input ?:

          Here is my FIRST usage of cout / cin using QT console.

          What exactly do you mean with "Qt console"? I assume that you are using Qt Creator here. Is that right? Do you mean the integrated output pane of Qt Creator? Do you set Qt Creator to run the app in a separate terminal? What operating system are you using? Windows 10?

          In addition to the answers so far, this might play a role if @JonB's answer does not help so far.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tuan.dt1
            wrote on last edited by
            #5

            You must tick run in terminal if you create CMake project with C++
            ae7dbd47-301b-42cd-a041-eb2468ae9fca-image.png

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved