了解Visual C++控制台项目中的_tmain

Who*_*ian 11 c++ visual-c++

在Visual C++ 2008 Express中,当我创建一个新的控制台项目时,我得到以下程序:

//Explodey.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

int _tmain(int argc,_TCHAR* argv[])
{
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我有几个问题:

  • 为什么主函数_tmain而不是main?

  • 我认为该argv参数应该是char* argv[]代替_TCHAR.

  • 什么stdafx.h

这并不像我习惯的C++那样.

Ini*_*eer 3

看看这里的 _tmain... 等等。

C++ 中 _tmain() 和 main() 有什么区别?

stdafx.h 是 Windows 应用程序的预编译头(可选)。更多这里:

http://en.wikipedia.org/wiki/Precompiled_header