0

Guys in cpp I create a program has variable x and this program ask for the user input to give the value of x like this program :

int x; cin>> x; How can I make the user to re -input the value of x with cleaning the first input without writing cin twice

2nd Aug 2019, 3:31 PM
PONAGAMA
2 ответов
+ 1
Use loops
2nd Aug 2019, 3:35 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
I usually do it with a loop int a = 0; int x; while ( a == 0){ cin>>x; a++; } Don't know what this achieves though :p
2nd Aug 2019, 3:37 PM
HNNX 🐿
HNNX 🐿 - avatar