why no response to my cin input ?
-
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:qno 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....
-
two things:
- insert std::flush after your "Enter Password" prompt
- make i an std::string
As for now seeing output, you should see output only after flushing cout.
-
@Kent-Dorfman said in why no response to my cin input ?:
insert std::flush after your "Enter Password" prompt
@AnneRanch
Actually, afterstd::cout << "Enter password: ";
is not where you need yourstd::flush()
orstd::endl
. Because that is followed by astd::cin >> i;
it auto-flushes, as you see in the output you show. You need it after yourstd::cout << "Password entered is " << i;
, e.g.std::cout << "Password entered is " << i << std::endl;
-
@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.