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 RĂ©ponses
+ 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