windows wmain 和 main 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2438049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between wmain and main?
提问by Rella
So I have some class starting with
所以我有一些课程开始
#include <wchar.h>
#include <stdlib.h>
and there is a wmain
function .
并且有一个wmain
函数。
How is it different from main function i usually use in my C/C++ programs?
它与我通常在 C/C++ 程序中使用的 main 函数有何不同?
采纳答案by Corey
"If your code adheres to the Unicode programming model, you can use the wide-character version of main, which is wmain."
“如果您的代码遵循 Unicode 编程模型,您可以使用宽字符版本的 main,即 wmain。”
http://msdn.microsoft.com/en-us/library/aa299386%28VS.60%29.aspx
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
}
回答by JaredPar
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
main
和之间的区别wmain
是用于表示程序参数的类型。该main
功能使用正常char
,而wmain
使用wchar_t
它可以接受Unicode值
回答by jcoder
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.
main 是 c & c++ 中的正常程序入口点,并以单字节字符传递给命令行。wmain 是在许多 Windows 程序中用于 unicode 程序的替代方法,在那里它作为宽 16 位 unicode 字符传递到命令行。
I believe it's a windows extension for unicode programs.
我相信它是 unicode 程序的 Windows 扩展。