Is there a way to lable a section of code so if a choice is entered it will take the program to a certain peice of code?
Programmer88
0
Newbie Poster
Recommended Answers
Jump to PostNever use goto statements - it's very bad programming practice! Why not just place your "certain piece of code" in a separate function and call it when the user makes a choice?
For example (using pseudocode - I haven't done C/C++ for a while):
If userChoice …
Jump to PostOne often-used choice is a switch statement:
assuming 'command' is one char: switch (command) { case 'w': // the following code is executed when (command == 'w') MoveFowardOneStep(); break; // break here means 'break out of the switch statement' case 'a': case 'A': // here, the following …
Jump to Post>Never use goto statements - it's very bad programming practice!
Moo, tell me, how does it feel to be cattle? I mean, you have to be a part of the herd if you mindlessly believe what you just stated.*sigh* This argument is tiresome, so I'll leave you with …
All 11 Replies
Programmer88
0
Newbie Poster
Coconut Monkey
40
Inside your PC
Team Colleague
Chainsaw
12
Posting Pro in Training
harshchandra
-3
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
1o0oBhP
4
Posting Pro in Training
Coconut Monkey
40
Inside your PC
Team Colleague
jwenting
1,889
duckman
Team Colleague
Coconut Monkey
40
Inside your PC
Team Colleague
jwenting
1,889
duckman
Team Colleague
Coconut Monkey
40
Inside your PC
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.