Link to home
Start Free TrialLog in
Avatar of broocrypt
broocrypt

asked on

Difference between "void main()" and "int _tmain(int argc, _TCHAR* argv[])"?

Hello. I am learning C++ and I am following a series of educational videos + some books. All these
books declare the main function as

void main()

However, when I downloaded and installed VC++ Express 2008 the default main declaration is

int _tmain(int argc, _TCHAR* argv[])

The programs run fine as well, but I really don't understand what's the difference, and it really bugs me the fact that I am using something I don't really understand. Adding to the confusion there's the fact that the videos I am
using use Microsoft Visual C++ as well (although I can tell it is not the 2008 version, probably an older one.)

So, basically what I would really know is:

1. The difference between the two declarations
2. Which one of the two should I consider "standard"
3. If there's really no standard to speak of,  but it is something strictly linked to my actual development environment, which in this case is VC++ 2008 Express.

Thank you. :)

(By the way, just in case it wasn't already clear, I'm a beginner as a beginner could be.)
SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Too slow :) ... sorry for the repeated points
Avatar of wktang83
wktang83

Yes I agree with sunnycoder.

The only standard in C++ is
int main()
or
int main(int argc, char* argv[]) (if you want to pass in parameters through command line)

This (int _tmain(int argc, _TCHAR* argv[])) is Windows specific, and is specific to the Visual Studio environment only.
Avatar of broocrypt

ASKER

Thank you everyone. Super clear now. It seemed unfair to give all the points to just one expert, since almost everyone added something to others' answers and viceversa. I divided them based on usefulness and effort. Hope you guys don't mind. Don't worry - as a beginner I will post a LOT more questions to gain points with. :))