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,,,

Recommended Answers

All 3 Replies

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

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.

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.