本帖最后由 jhq999 于 2022-3-10 12:30 编辑
你返回函数的指针干啥,而且函数指针可以返回struct Book* addBook(struct Book* library) 我想问一下这里如果在传值的时候不传入它的地址,那只用一个*不应该是一样的吗
{
struct Book* book, * temp;
book = (struct Book*)malloc(sizeof(struct Book));
if (book == NULL)
{
printf("内存分配失败了!");
exit(1);
}
getInput(book);
if (library != NULL)
{
temp = library;
library = book;
book->next = temp;
}
else
{
library = book;
book->next = NULL;
}
return library;
}
typedef int (*addpoint)(int, int);
int add(int a,int b)
{
return a+b;
}
addpoint test()
{
return add;
}
int main(int argc,char *argv[])
{
addpoint fun=test();
printf("%d",fun(1,3));
return 0;
}
|