
November 25th, 2004, 11:47 PM
|
 |
Contributing User
|
|
Join Date: Apr 2004
Location: Frostbite capital of the world
Posts: 542
 
Time spent in forums: 16 h 58 m 34 sec
Reputation Power: 10
|
|
i'd suggest changing choice to a char instead of having it as an int. That way if the user enters are char by mistake it won't kill the program. You'd then have to change:
if (choice==1)
to:
if (choice=='1');
if else (choice==2){
should be
else if
And you might want to include a loop in there so if the choice entered is not 1 or 2, the user is asked again.
Code:
char choice='*';
while (choice!='1'&&choice!='2'){
cout<<"There are two choices\n float and integer\n press 1 for float, 2 for integer";
cin>>choice;
}//end while
edit:
you should probably rewind(stdin) after your cin>>choice to clear the buffer.
Last edited by fisch : November 25th, 2004 at 11:57 PM.
|