Click here to Skip to main content
15,921,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to get index of minimum of one array Pin
Steve Echols4-Feb-08 17:30
Steve Echols4-Feb-08 17:30 
GeneralRe: how to get index of minimum of one array Pin
gentleguy4-Feb-08 20:59
gentleguy4-Feb-08 20:59 
AnswerRe: how to get index of minimum of one array Pin
pierre_ribery4-Feb-08 20:54
pierre_ribery4-Feb-08 20:54 
QuestionGet coordinate of mouse click Pin
Kennis4-Feb-08 14:22
Kennis4-Feb-08 14:22 
GeneralRe: Get coordinate of mouse click Pin
Steve Echols4-Feb-08 17:36
Steve Echols4-Feb-08 17:36 
QuestionWhat's the rule for "cleaning" and "rebuilding"...? Pin
@largeinsd4-Feb-08 13:46
@largeinsd4-Feb-08 13:46 
QuestionVS2008 sends to IP 224.0.0.22 ?! Pin
Ingo H. de Boer4-Feb-08 11:41
Ingo H. de Boer4-Feb-08 11:41 
GeneralInput (istream) error testing Pin
hain4-Feb-08 9:15
hain4-Feb-08 9:15 
I want to test for an invalid character in entered numeric (integer) data,
(e.g., enter "d23", instead of "123")

In the following code, the do loop loops infinitely after
an invalid entry, "d23". Seems like cin is not stopping to
accept more input the second time around.

Can anyone tell me what I'm doing wrong?

Thanks,
Tom

------------------------
#include <iostream>
using namespace std;

void main()
{
int x;
cout << "Type in an integer value: ";
cin >> x;
while (cin.fail())
{
cin.clear();
cout << "Invalid character.\n Type in an integer value: ";
cin >> x;
}
cout << x << endl;
}
QuestionRe: Input (istream) error testing Pin
David Crow4-Feb-08 10:14
David Crow4-Feb-08 10:14 
GeneralRe: Input (istream) error testing Pin
gentleguy4-Feb-08 22:14
gentleguy4-Feb-08 22:14 
GeneralRe: Input (istream) error testing Pin
hain5-Feb-08 5:23
hain5-Feb-08 5:23 
GeneralRe: Input (istream) error testing Pin
David Crow5-Feb-08 5:37
David Crow5-Feb-08 5:37 
GeneralRe: Input (istream) error testing Pin
hain6-Feb-08 3:42
hain6-Feb-08 3:42 
GeneralPSM_QUERYSIBLINGS Pin
bob169724-Feb-08 6:25
bob169724-Feb-08 6:25 
GeneralRe: PSM_QUERYSIBLINGS Pin
Mark Salsbery4-Feb-08 6:36
Mark Salsbery4-Feb-08 6:36 
QuestionRe: PSM_QUERYSIBLINGS Pin
bob169724-Feb-08 6:54
bob169724-Feb-08 6:54 
GeneralRe: PSM_QUERYSIBLINGS Pin
Mark Salsbery4-Feb-08 7:09
Mark Salsbery4-Feb-08 7:09 
GeneralRe: PSM_QUERYSIBLINGS Pin
bob169724-Feb-08 7:40
bob169724-Feb-08 7:40 
QuestionRe: PSM_QUERYSIBLINGS Pin
David Crow4-Feb-08 6:41
David Crow4-Feb-08 6:41 
GeneralRe: PSM_QUERYSIBLINGS Pin
bob169724-Feb-08 6:49
bob169724-Feb-08 6:49 
QuestionRe: PSM_QUERYSIBLINGS Pin
David Crow4-Feb-08 7:34
David Crow4-Feb-08 7:34 
GeneralRe: PSM_QUERYSIBLINGS Pin
bob169724-Feb-08 7:50
bob169724-Feb-08 7:50 
GeneralRe: PSM_QUERYSIBLINGS Pin
David Crow4-Feb-08 8:01
David Crow4-Feb-08 8:01 
GeneralRe: PSM_QUERYSIBLINGS Pin
bob169724-Feb-08 9:13
bob169724-Feb-08 9:13 
GeneralCControlBarInfo Pin
CString(0xcccccccc)4-Feb-08 3:57
CString(0xcccccccc)4-Feb-08 3:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.