请大家来帮我看下这个C语言编程调试问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 04:03:35
#include "stdio.h"
void main()
{
printf("%d",age(5));
}
age(int n)
{
int c;
if(n==1)
c=10;
else
c=age(n-1)+2;
return c;
}

我把这个程序放在TC里面调试运行完全没问题,但是放在VS2005版里加上#include "stdafx.h"文件头,调试出现以下问题:
cpp(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
请大家帮我看看啊~~~

#include<stdio.h>
int main()
{
int age(int n);
printf("%d",age(5));
return 0;
}
int age(int n)
{
int c;
if(n==1)
c=10;
else
c=age(n-1)+2;
return c;
}

你的程序就是放到vs2010版里也不用加上#include "stdafx.h"
因为这只是个console程序

你没有在main函数里面生命age函数吧。
void main()
{
int age(int n);
printf("%d",age(5));
}
这样试一下

#include "stdio.h"
age(int n)
{
int c;
if(n==1)
c=10;
else
c=age(n-1)+2;
return c;
}
void main()
{
printf("%d",age(5));
}
非主函数要先声明或写在主函数上面