TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Michael Gleason
date: 1995-07-03 21:38:04
subject: Simple ? (I hope)

I have a simple question. I hope it has a simple answer.
I am looking for a way to use switch / case with a changable number of items.
As a simple undeclared, unformatted example......

   scanf(" %c", &choose);
   switch (choose)
  {  case ('1'): { show(1);
                 break; }
     case ('2'): { show(2);
                 break; }
     case ('3'): { show(3);
                 break; }
     case ('4'): { show(4);
                 break; }                            
     case (???): { Etc, etc, etc, etc..........
                 break; } 
     case ('A'): { abort();
                 break; } 
     default : { printf("Unknown command");
                break; }
  }
}
show(1)
{
   printf("showing number 1 ");
   etc...... 
}

That was a very bad example but I am hoping that it gives an idea of what I
am wanting to do.
The amount of choices will always be different and therefore so will the
number of cases.
I would like to know if I should dump this idea or if I am missing an easy
step. 
Also this is not a good example but I'm typing this fast....
Thank you for any help.
Mike.

--- VFIDO 7.00.05
* Origin: The GATE OS/2 V3.0 / V.34 / Key West Fl. (1:135/813)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 135/813 292 94 3615/50 396/1 270/101 105/103 42 712/515 711/808 809
@PATH: 711/934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.