分类: C/C++
2008-01-17 10:09:09
============================================================
maoyong:2008.1.17
============================================================
#include
#include
int a(char *name)
{
printf("a: my name is %s\n",name);
return 0;
}
int b(char *name)
{
printf("b: my name is %s\n",name);
return 0;
}
int c(char *name)
{
printf("c: my name is
%s\n",name);
return 0;
}
int d(char *name)
{
printf("d:
my name is %s\n",name);
return 0;
}
int e(char *name)
{
printf("e: my name is %s\n",name);
return 0;
}
int f(char
*name)
{
printf("f: my name is %s\n",name);
return
0;
}
int g(char *name)
{
printf("g: my name is
%s\n",name);
return 0;
}
typedef int (*pFUN)(char *name);
int main()
{
pFUN fun[7];
fun[0] = a;
fun[1] =
b;
fun[2] = c;
fun[3] = d;
fun[4] = e;
fun[5] =
f;
fun[6] = g;
int fun_choose;
char name[50];
printf("please entry the
number:
0 call a(), 1 call b(),etc\nchoose:");
scanf("%d",&fun_choose);
printf("please entry the name:");
scanf("%s",name);
(*fun[fun_choose])(name);
printf("very
well\n");
return 0;
}