各位能看看嘛?
我把返回结果(指针类型)赋值给相同类型的一个指针,报错显示:应输入表达式
```c
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
typedef struct function
{
char* func_name;
void (*func_pointer)(void);
}function_list;
int add(int a, int b);
int add(int a, int b) {
return a + b;
}
int compare(int a, int b);
int compare(int a, int b);
int compare(int a, int b) {
return a > b ? a : b;
}
int equal(int a, int b);
int equal(int a, int b) {
if (a == b)
return 1;
else 0;
}
int *find(char u, function_list *a) {
while (strcmp(a->func_name,u)!=0)
{
*a++;
}
if (strcmp(a->func_name, u) != 0)
{
printf("未找到相关函数");
return 0;
}
else
{
return a->func_pointer;
}
}
int main() {
int(*p)(int, int);
p = add;
int (*q)(int, int);
q = compare;
int(*r)(int, int);
r = equal;
function_list a[] = {
{"add",*p},
{"compare",*q},
{"equal",*r}
};
char t;
printf("input function name that you want:\n");
scanf("%s", &t);
int* i = find(t, a);
}