一道简单的题目,求解哪里错了
//求前n项的和,函数调用哪里错了//#include <stdio.h>
void main()
{
int i;
int sum(int n);
printf("请输入一个数:\n");
scanf("%d",&i);
sum(i);
printf("前%d项的和为:%d\n",i,sum);
}
int sum(int n)
{
int i;
if (i==1) n=1;
else n=sum(n-1)+n;
return n;
}
//错误提示如下warning C4700: local variable 'i' used without having been initialized//