调用函数时,“函数链接失败?”
程序目的:设有n个人,年龄都相差2岁,输入一个数字n,使用递归函数进行求解。程序代码:
#include<stdio.h> unsigned int ComputeAge(unsigned int n); unsigned int computeAge(unsigned int n){ if(n==0)return 0; if(n==1)return 10; else return computeAge(n-1)+2; } int main(){ unsigned int x=0,y; scanf("%u",&x); y=ComputeAge(x);//程序报错的位置在此,“undefined reference to 'ComputeAge(unsigned int)'”我猜这句话的意思是找不到函数 printf("The person's age is %u\n",y); return 0; }
还是说我用%u来获取x的值时失败了?