void PrintN(int N)
{
if (N){
PrintN(N-1);
printf("%d\n",N);
}
return;
}
void PrintN(int N)
{
int i;
for (i=1;i<=N;i++){
printf("%d\n",i);
}
return;
}
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int N;
scanf("%d", &N);
PrintN(N);
return 0;
}
出现的问题:
1.“stdafx.h”: No such file or directory
解决://#include "stdafx.h"
2._TCHAR* has not been declared
解决:
没有引用包含_TCHAR的头文件,可以引用<tchar.h> #include <tchar.h> 其实可以把_TCHAR换成char
3.undefined reference to `WinMain@16'
解决:意思为提示找不到 WinMain 函数 原因是多写了一个main()
_tmain: 1. Main是所有c或c++的程序执行的起点,_tmain是main为了支持unicode所使用的main的别名。_tmain()不过是unicode版本的的main(). 2. _tmain需要一个返回值,而main默认为void. 3. _tmain的定义在<tchar.h>可以找到,如#define _tmain main,所以要加#include <tchar.h>才能用。_tmain()是个宏,如果是UNICODE则他是wmain()否则他是main(). int argc //表示参数个数 char *argv[] //表示各个参数,字符串数组的每个单元是char*类型的,指向一个c风格字符串。 //_TCHAR类型是宽字符型字符串,和我们一般常用的字符串不同,它是32位或者更 高的操作系统中所使用的类型.