c++visual-studioheaderstdafx.h

C++ header file in Visual Studio


Okay. So I've got a simple question. If I ask it in the wrong place, please correct me. What I want to ask is, why Visual Studio gives me this:

#include "stdafx.h"


int main()
{
    return 0;
}

everytime I create a new project? (I know I can select Empty Project, and add mine .cpp file by myself, but I'm just curious. It says #include <stdio.h> and #include <tchar.h>. So what is it for? Are you all using it or something?

And P.S - why there is no (int argc, char** argv) in main declaration? (on my coding course in college I've learned that there may be _tmain(int argc, _TCHAR* argv), when creating something in VS)


Solution

  • Okay. So I've got a simple question. If I ask it in the wrong place, please correct me. What I want to ask is, why Visual Studio gives me this: ...

    Well, it depends a bit on the project type you've been choosing from the wizard. Looks like the standard template for a console project.

    #include "stdafx.h"
    

    is prepended for any type of translation unit by the wizard. It supports the precompiled header optimizaton mechanism.


    why there is no (int argc, char** argv) in main declaration?

    Because the template provides the minimum for a valid main() entry routine definition.