Get input example

97 views
Skip to first unread message

ALONSO MANUEL PEREZ GUANILO

unread,
May 16, 2023, 6:18:21 PM5/16/23
to C++ GCU Forum
Hi everyone!
I want to know why in the second example of c++ course of the Getting Started I cannot get the sentence in the if conditional: if(!(cin>>input_var)){ cout<<"You entered a non-numeric. Exiting..."<<endl;

It doesn't work because I use windows and not linux? or because my IDE it's different. I use NetBeans.

Jai Bhardwaj

unread,
May 28, 2023, 12:49:49 AM5/28/23
to C++ GCU Forum
Can I get the screenshot of the error that you are getting?
In the if condition we are trying to get the input from the console and storing it in a variable( input_var ) it is most probably of integer type although you have not mentioned it. And if you'll enter any character or a string in the input this "if" block will execute.
Reply all
Reply to author
Forward
0 new messages