-
goto or not goto
howdy,
i understand that goto :eek: is to be avoided so in the following switch what is the proper way of getting back to case'y' without starting the complete switch over again?
Code:
switch(pick){
case 'm':
case 'M':
{answer = static_cast <int> (rand())%high_range;}
break;
case 'y':
case 'Y':
enter: //<<<<--------------------------
cout<<"Enter a number"<<endl;
cin>>hi_range;
if(!IsIntt (hi_range)){ //check for int
cout<<"Must be an integer"<<endl;
goto enter;} //<<<<------------------
else
high_range = atoi (hi_range);
cout<<"hi: "<<hi_range<<"high: "<<high_range<<endl;
break;
};
thanks
M.R.
-
-
Code:
switch(pick){
case 'm':
case 'M':
{answer = static_cast <int> (rand())%high_range;}
break;
case 'y':
case 'Y':
int flag = 1;
while(flag == 1)
{
cout<<"Enter a number"<<endl;
cin>>hi_range;
if(!IsIntt (hi_range)){ //check for int
cout<<"Must be an integer"<<endl;
else
{
flag = 0;
high_range = atoi (hi_range);
cout<<"hi: "<<hi_range<<"high: "<<high_range<<endl;
}
}
break;
};
-
wow
howdy,
after i post these things and see the replies it occurs(sp) to me that i am trying to over complicate this stuff
itld trys to remeber KISS.
thanks all
M.R.