We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,451 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Integer checking?

User is supposed to type an input, and if it's not an integer, the user needs to type another.
This repeats 3 times for 3 inputs which go inside an array.

The integer checking works, but the problem is that when i display the 3 integers, they are all the same number (the first correct input). Idk what's wrong. I've tried cin.clear() and cin.sync()...

for(int i=0;i<3;i++){
cout<<"Enter your "<<text[i+6]<<": ";
cin.sync();
cin.clear();
cin>>inInt[i];
if(!cin){
cout<<"\nPlease enter a valid integer.";
i--;
system("pause");}
system("cls");}
2
Contributors
1
Reply
32 Minutes
Discussion Span
4 Months Ago
Last Updated
2
Views
nullifyQQ
Newbie Poster
5 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

What does your display loop look like?

deceptikon
Challenge Accepted
Administrator
3,459 posts since Jan 2012
Reputation Points: 822
Solved Threads: 474
Skill Endorsements: 57

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1399 seconds using 2.67MB