How do you put a case ' ': in a while loop?
Could you give an example
thanks
jay
How do you put a case ' ': in a while loop?
Could you give an example
thanks
jay
why are you putting a case in a while loop? a case should be in a switch
Can you give a switch w/ case example then?
sorry, been a long time since I did any C I/O. The printf and sscanf syntax isn't the important part anyway.Code:int choice; printf("%d", "enter an int between 1 and 3"); sscanf("%d", &choice); switch(choice) { case 1: //do something here break; case 2: //do something else here break; case 3: //do something really weird here break; default: break; }
You're only born perfect.
Sure you can put a case in a while loop:
Now in this case you'd want to have something in there that actually changes the value of c, but you get the idea.Code:while( c != 'q' ) { switch( c ) { case 'a': printf("You selected \'a\'.\n" ); break; case 'b': printf("You selected \'b\'.\n" ); break; default: printf("You didn't select anything useful.\n"); } }
Quzah.
Hope is the first step on the road to disappointment.
Originally Posted by eladnow it's okCode:printf("enter an int between 1 and 3\n");