Code Wizard
04-11-2004, 04:46 PM
In C++ if an integer value is expected,and the user enters a character,what value shall the variable actually take?
int n;
cout<<"n=";
cin>>n;
And also,what sort of validation is it best to use?
For example,this won't work:
int n;
do
cout<<"Enter a number:";
while(!(cin>>n));
:confused:
int n;
cout<<"n=";
cin>>n;
And also,what sort of validation is it best to use?
For example,this won't work:
int n;
do
cout<<"Enter a number:";
while(!(cin>>n));
:confused: