What is the difference between wmain and main?

試著忘記壹切 提交于 2019-11-27 03:52:30

问题


So I have some class starting with

#include <wchar.h>
#include <stdlib.h>

and there is a wmain function .

How is it different from main function i usually use in my C/C++ programs?


回答1:


"If your code adheres to the Unicode programming model, you can use the wide-character version of main, which is wmain."

http://msdn.microsoft.com/en-us/library/aa299386%28VS.60%29.aspx

main( int argc, char *argv[ ], char *envp[ ] )
{
program-statements
}

wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] )
{
program-statements
}



回答2:


The difference between main and wmain is the type used to represent the arguments to the program. The main function uses normal char while wmain uses wchar_t which can accept unicode values

  • http://msdn.microsoft.com/en-us/library/aa299386(VS.60).aspx



回答3:


main is the normal program entry point in c & c++ and is passed the command line in single byte characters. wmain is an alternative that is used in many windows programs for unicode programs where it instead gets passed the command line as wide 16 bit unicode characters.

I believe it's a windows extension for unicode programs.



来源:https://stackoverflow.com/questions/2438049/what-is-the-difference-between-wmain-and-main

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!