How can i extract information inside the switch statemnt to outside in c langauge.... for eg.

i want the information of case 3 to display out the switch statement, then how can i do ? plz respond,,,

4 Years
Discussion Span
Last Post by DavidB

Your question makes no sense. Can you provide a detailed example of what you want to happen?

Edited by deceptikon


i think you have store that information in global varibale..
but provide some code here to explain in better way...
i don't get your question,what you want to ask.?



Depending how much information you want to transfer out of the switch statement, you might have to use several temporary variables.

For example, say the integer variable TestVar equals 6 and caused Case 3 to be true.
If you went straight to a break from there, you would know that TestVar equals 6. Not much information tranmitted out of the switch statement there.

However, if you set a few flag variables before doing the break, you could transmit more info. For example:

Case 3: flag1 = 1;
    flag2 = 2;
    flag3 = 0;

By doing this, you could break out of the switch and also provide some ways to direct how the rest of the program should execute.

For example,

if (flag1){
  proceed to take course 1

if (flag2 != 2){
  execute other statements

That is one way of doing it.
Hopefully, you get the idea.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.