C++ Need Help!!
Dyno247365
10-16-2006, 11:14 PM
I want to use a variable in a switch statement, is it possible?
Switch(total)
{
case whatever:
break;
case 2:
break;
}
doesn't work much.
Switch(total)
{
case whatever:
break;
case 2:
break;
}
doesn't work much.
Dyno247365
10-17-2006, 12:02 AM
umm this thread needs priority right now, can I use anything other than a case? Because it says it has to be a constant but I need to identify a VAR.
vinnym86
10-17-2006, 12:59 AM
you could use IF and ELSE statements. those are more basic than CASE statements, less versatile i think. sry, been a while since i've done qbasic and C++.
Dyno247365
10-17-2006, 02:25 AM
you could use IF and ELSE statements. those are more basic than CASE statements, less versatile i think. sry, been a while since i've done qbasic and C++.
I tried that already, for some reason it's telling me to declare Int For () which is really stupider than it even sounds. Maybe you know what i did wrong but I've already been told by a couple people to use if/else I just don't know why it won't work. I'm using Pico, let me try it again right now, PuTTy is great since I can get on my college's network!
I tried that already, for some reason it's telling me to declare Int For () which is really stupider than it even sounds. Maybe you know what i did wrong but I've already been told by a couple people to use if/else I just don't know why it won't work. I'm using Pico, let me try it again right now, PuTTy is great since I can get on my college's network!
Dyno247365
10-17-2006, 02:40 AM
I figured it out, it's a craps game program. I said that if the current total equals the total it got last time (temp_dice), it turns total into 0, which isn't one of the cases for a dice total, so I made case 0: for when you win the game. so that's the way i got it to work. It doesn't work yet but I believe it's right this way. Before I was using else for going into the switches and it didn't work.
Automotive Network, Inc., Copyright ©2026
