A brief analysis of the difference between _tmain () and main () _c language

Source: Internet
Author: User

There are so two lines

#include <stdio.h>

#include <tchar.h>

We can find the _tmain macro definition in header file <tchar.h>

#define _tmain Main

So, after precompiling, _tmain becomes main.

Main () is a function entry for standard C + +. Standard C + + program entry point function, default character encoding format ANSI

The function signature is:

int main ();

int main (int argc, char* argv[]);

_tmain () is a program entry point function that Windows provides for automatic conversion of the Unicode character set and the ANSI character set.

The function signature is:

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

When your program's current character set is Unicode, int _tmain (int argc, TCHAR *argv[]) is translated into

int wmain (int argc, wchar_t *argv[])

When your program's current character set is ANSI, int _tmain (int argc, TCHAR *argv[]) is translated into

int main (int argc, char *argv[])

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.