|
|
| Search | Car Forums | Gallery | Articles | Helper | Air Dried Fresh Beef Dog Food | IgorSushko.com | Corporate |
|
|||||||
| COMPLETELY off-topic Talk about anything other than cars. But you can't be mad and angry in this forum! |
![]() |
Show Printable Version |
Subscribe to this Thread
|
|
|
Thread Tools |
|
#1
|
||||
|
||||
|
C++ Need Help!!
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.
__________________
![]() 1996 Dodge Ram 1500 5.2L 5spd!!! 1987 Chevy Iroc-Z- -Needs a new cat 1992 Nissan 240sx 5spd- SOLD |
|
#2
|
||||
|
||||
|
Re: C++ Need Help!!
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.
__________________
![]() 1996 Dodge Ram 1500 5.2L 5spd!!! 1987 Chevy Iroc-Z- -Needs a new cat 1992 Nissan 240sx 5spd- SOLD |
|
#3
|
||||
|
||||
|
Re: C++ Need Help!!
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++.
__________________
|
|
#4
|
||||
|
||||
|
Re: C++ Need Help!!
Quote:
__________________
![]() 1996 Dodge Ram 1500 5.2L 5spd!!! 1987 Chevy Iroc-Z- -Needs a new cat 1992 Nissan 240sx 5spd- SOLD |
|
#5
|
||||
|
||||
|
Re: C++ Need Help!!
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.
__________________
![]() 1996 Dodge Ram 1500 5.2L 5spd!!! 1987 Chevy Iroc-Z- -Needs a new cat 1992 Nissan 240sx 5spd- SOLD |
|
![]() |
POST REPLY TO THIS THREAD |
![]() |
|
|