In VS which kind of new project the main function has parameters

When I new a project in VS, which kind of new project the main function has parameters, sucn as "int main (argc int, **argv char)".
In addition, the new VS project CPP files seems Automatically add "#include "stdafx.h"",delete this will lead to an error; But a lot of open source projects the cpp files do not contains the"#include "stdafx.h"", which also pass through the VS compiler, why? thank you!!!
In a project, "properties-〉general->Target Name" is "aaaaa", "properties-〉general->Target Extension" is ".exe",but "Linker-〉Advanced->Import Library" is "aaaaa.lib", why a exe project can creat a .lib file?
There are several valid signatures for the main function:

1
2
3
4
5
int main()

int main(int argc, char argv[])

int main(int argc, char** argv)


The first two are valid according to the standard, and the third one is equivalent to the second one.

'argc' is an integer that represents the number of arguments passed to the program.
'argv' is a pointer to an array of C-strings, representing the actual arguments themselves.

Common implementations will set the first argument 'argv[0]' to the program name if it is available - the effect of which is that your program will have at least one argument passed to it - it's own name.

"stdafx.h" is a precompiled header: http://stackoverflow.com/questions/4726155/whats-the-use-for-stdafx-h-in-visual-studio

I've never found a reason to use it though.

If you wish to disable the these things, when creating a new project, make sure to check "Empty project", and un-check "Precompiled header" under the additional options in the project creation prompt.

An "Empty project" will not have any code or files to start with. This prevents the self-inserted main function etc.

Un-checking the "Precompiled header" disables "stdafx.h".
Last edited on
Thank you xismn for your reply, and still the 3rd question, why can a .exe project can creat a .lib file at the same time?
Thanks again.
Topic archived. No new replies allowed.