12

In Visual C++ 2008 Express, when I create a new console project I get the following program to start with:

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

//

#include "stdafx.h"

int _tmain(int argc,_TCHAR* argv[])
{
  return 0;
}

I have a few questions about it:

  • Why is the main function _tmain instead of main?

  • I'd thought the argv parameter was supposed to be char* argv[] instead of _TCHAR.

  • What's stdafx.h?

This doesn't really feel like the same C++ I'm used to.

Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
Whovian
  • 365
  • 2
  • 4
  • 12
  • possible duplicate of [What is the difference between _tmain() and main() in C++?](http://stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c) – Adrian McCarthy May 04 '12 at 16:40
  • True, but at the time of posting, I didn't even know main() was a legal main function in Visual C++. – Whovian May 04 '12 at 20:51
  • I understand. Just trying to help out the next programmer who comes along with a similar question. The answers in the other question are a little more comprehensive. – Adrian McCarthy May 07 '12 at 21:17

1 Answers1

3

Take a look here for _tmain... etc.

What is the difference between _tmain() and main() in C++?

stdafx.h is a precompiled header (optional) for Windows applications. More here:

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

Community
  • 1
  • 1
Inisheer
  • 20,376
  • 9
  • 50
  • 82
  • 1
    If you remove the precompiled header include you must also change the project settings under "Precompiled Headers" or you'll get compile errors. – Mark Ransom May 04 '12 at 16:54