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 Answers
+ 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