| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Simple ? (I hope) |
Hallo, Michael!
*** Am Montag 03. Juli 1995 um 21:38 schrieb Michael Gleason an All:
MG> I am looking for a way to use switch / case with a changable number of
MG> items.
Use an array of function pointers and take the input (or whatever) as an
index into this array.
#include
typedef void (*vfunci)(int);
typedef vfunci funcarray[3];
void func1(int x) { puts("f1"); }
void func2(int x) { puts("f2"); }
void func3(int x) { puts("f3"); }
funcarray myfuncs={ func1, func2, func3 };
int main(int argc, char **argv) {
int choice=2;
(*myfuncs[choice])(38);
return 0;
}
Tschau...Thomas
--- E3-32/1.11-32/2.50+
* Origin: TeX-Box +49-6034-1455 ZyXEL 16800 24h (2:244/1130.42)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: 244/1130 24/999 2/777 105/42 712/515 711/808 809 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™.