#include <stdio.h>
#include <string.h>
typedef struct tcb{
char *code_name;
int p;
int v_num;
void (*fun)();
}TCB;
void function1()
{
char i;
for(i=0;i<10;i++)
printf("11111111\n");
}
void function2()
{
char i;
for(i=0;i<10;i++)
printf("2222222\n");
}
void function3()
{
char i;
for(i=0;i<10;i++)
printf("333333\n");
}
TCB creat(char *name,int pp,int vnum,void (*fun)())
{
TCB tcb;
tcb.code_name = name;
tcb.p = pp;
tcb.v_num = vnum;
tcb.fun = fun;
return tcb;
}
main()
{
char code_name[10];
int t=0,i;
TCB tabTbl[3];
tabTbl[0] = creat("F1",2,1,function1);
tabTbl[1] = creat("F2",2,4,function2);
tabTbl[2] = creat("F3",4,5,function3);
printf("Input codename:");
scanf("%s",code_name);
for(i=0;i<3;i++)
{
if(strcmp(tabTbl[i].code_name,code_name)==0)
{
tabTbl[i].fun();
t=1;
}
if((i==2)&&(t==0))printf("No %s\n",code_name);
}
getchar();
}