I am trying out CLion to write some basic C++ programs but every time I feed in some input using std::cin
or std::getline
the input is printed back to the console for no reason.
For example if I run this program
#include <iostream>
#include <string>
int main(){
string name;
std::cin >> name;
std::cout << name << std::endl;
return 0;
}
and type thomas and press enter I get this output
thomas
thomas
thomas
when instead I should get just
thomas
thomas
I am using CLion/Mingw64 on Windows 10 x64
There's nothing wrong with your code.
What you observe is a side effect of using WinPTY under the hood. By default, CLion uses it to communicate with a debugged program on Windows.
Here's the corresponding bug in our issue tracker: CPP-2580 User input appears twice in output window in CLion under MinGW, please feel free to upvote the ticket.
While there's no proper fix for the issue yet, you may use a workaround suggested in comments to that ticket to disable PTY:
Open Registry via Find Action, type
run.processes.with.pty
and disable this pty setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With