關於函式指標

深海大大發表於2020-10-12

#include <stdio.h>

int Fibo(int n)
{
if (!n)
return 0;
if (n == 1)
return 1;
return Fibo(n - 1) + Fibo(n - 2);
}

int (*f)(int);//函式指標.

int main()
{
int n;
scanf("%d", &n);
int a = Fibo(n + 1);
int b = Fibo(n);
printf("&a = %p\n&b = %p\n", &a, &b);
f = Fibo;//函式指標用法.
int *p = f;
printf(“p = %p\n”, p);
printf(“a + b = %d\n”, a + b);
return 0;
}

相關文章