公选课很水,闲得蛋疼,写了下命令行交互界面的结构,悲剧的是没有过。我的C实在是渣……现在想起来再写,倒是没什么问题。
#include
#include
#include
void foo(char** argc){
;
}
void say(char** argc){
printf("Hello~\n");
}
void hello(char** argc){
printf("World!\n");
}
void (*f[])(char** argc) = {foo,say,hello};
char* argcList[] = {"f","say","hello"};
int argcNum = 3;
int main(int argv, char** argc){
int i,j;
char** noth = NULL;
for(i=0;i
【更新】加了个结构体整理起来,其后又折腾了一轮无果,所以只是多了个结构体。
#include
#include
#include
typedef struct fun_map{
void (*fun)(char** argc);
char name[32];
}fMap,*fmPtr;
void foo(char** argc){
;
}
void say(char** argc){
printf("Hello~\n");
}
void hello(char** argc){
printf("World!\n");
}
const int argcNum = 3;
fMap funMap[3]={{foo,"foo"},
{say,"say"},
{hello,"hello"},
};
int main(int argv, char** argc){
int i,j;
for(i=0;i