欢迎来到天天文库
浏览记录
ID:34300028
大小:361.73 KB
页数:4页
时间:2019-03-04
《unicode - What is the difference between _tmain() and main() in C _ - Stack Overflow.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、Whatisthedifferencebetween_tmain()andmain()inC++?IfIrunmyC++applicationwiththefollowingmain()methodeverythingisOK:intmain(intargc,char*argv[]){cout<<"Thereare"<2、3、Itjustdisplaysthefirstcharacterofeachargument.Whatisthedifferencecausingthis?c++unicodeargumentsaskedMay21'09at23:45joshcomley5,7793326973%acceptratefeedback4Answers_tmaindoesnotexistinC++.maindoes._tmainisaMicrosoftextension.mainis,accordingtotheC++standard,theprogram'4、sentrypoint.Ithasoneofthesetwosignatures:intmain();intmain(intargc,char*argv[]);Microsofthasaddedawmainwhichreplacesthesecondsignaturewiththis:intwmain(intargc,wchar_t*argv[]);Andthen,tomakeiteasiertoswitchbetweenUnicode(UTF-16)andtheirmultibytecharacterset,they'vedefin5、ed_tmainwhich,ifUnicodeisenabled,iscompiledaswmain,andotherwiseasmain.Asforthesecondpartofyourquestion,thefirstpartofthepuzzleisthatyourmainfunctioniswrong.stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c1/4wmainshouldtakeawchar_targ6、ument,notchar.Sincethecompilerdoesn'tenforcethisforthemainfunction,yougetaprogramwhereanarrayofwchar_tstringsarepassedtothemainfunction,whichinterpretsthemascharstrings.Now,inUTF-16,thecharactersetusedbyWindowswhenUnicodeisenabled,alltheASCIIcharactersarerepresentedasth7、epairofbytes followedbytheASCIIvalue.Andsincethex86CPUislittle-endian,theorderofthesebytesareswapped,sothattheASCIIvaluecomesfirst,thenfollowedbyanullbyte.Andinacharstring,howisthestringusuallyterminated?Yep,byanullbyte.Soyourprogramseesabunchofstrings,eachonebytelong.8、Ingeneral,youhavethreeoptionswhendoingWindowsprogramming:ExplicitlyuseUnicode(callwmain,andforeveryWindowsAPIf
2、3、Itjustdisplaysthefirstcharacterofeachargument.Whatisthedifferencecausingthis?c++unicodeargumentsaskedMay21'09at23:45joshcomley5,7793326973%acceptratefeedback4Answers_tmaindoesnotexistinC++.maindoes._tmainisaMicrosoftextension.mainis,accordingtotheC++standard,theprogram'4、sentrypoint.Ithasoneofthesetwosignatures:intmain();intmain(intargc,char*argv[]);Microsofthasaddedawmainwhichreplacesthesecondsignaturewiththis:intwmain(intargc,wchar_t*argv[]);Andthen,tomakeiteasiertoswitchbetweenUnicode(UTF-16)andtheirmultibytecharacterset,they'vedefin5、ed_tmainwhich,ifUnicodeisenabled,iscompiledaswmain,andotherwiseasmain.Asforthesecondpartofyourquestion,thefirstpartofthepuzzleisthatyourmainfunctioniswrong.stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c1/4wmainshouldtakeawchar_targ6、ument,notchar.Sincethecompilerdoesn'tenforcethisforthemainfunction,yougetaprogramwhereanarrayofwchar_tstringsarepassedtothemainfunction,whichinterpretsthemascharstrings.Now,inUTF-16,thecharactersetusedbyWindowswhenUnicodeisenabled,alltheASCIIcharactersarerepresentedasth7、epairofbytes followedbytheASCIIvalue.Andsincethex86CPUislittle-endian,theorderofthesebytesareswapped,sothattheASCIIvaluecomesfirst,thenfollowedbyanullbyte.Andinacharstring,howisthestringusuallyterminated?Yep,byanullbyte.Soyourprogramseesabunchofstrings,eachonebytelong.8、Ingeneral,youhavethreeoptionswhendoingWindowsprogramming:ExplicitlyuseUnicode(callwmain,andforeveryWindowsAPIf
3、Itjustdisplaysthefirstcharacterofeachargument.Whatisthedifferencecausingthis?c++unicodeargumentsaskedMay21'09at23:45joshcomley5,7793326973%acceptratefeedback4Answers_tmaindoesnotexistinC++.maindoes._tmainisaMicrosoftextension.mainis,accordingtotheC++standard,theprogram'
4、sentrypoint.Ithasoneofthesetwosignatures:intmain();intmain(intargc,char*argv[]);Microsofthasaddedawmainwhichreplacesthesecondsignaturewiththis:intwmain(intargc,wchar_t*argv[]);Andthen,tomakeiteasiertoswitchbetweenUnicode(UTF-16)andtheirmultibytecharacterset,they'vedefin
5、ed_tmainwhich,ifUnicodeisenabled,iscompiledaswmain,andotherwiseasmain.Asforthesecondpartofyourquestion,thefirstpartofthepuzzleisthatyourmainfunctioniswrong.stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c1/4wmainshouldtakeawchar_targ
6、ument,notchar.Sincethecompilerdoesn'tenforcethisforthemainfunction,yougetaprogramwhereanarrayofwchar_tstringsarepassedtothemainfunction,whichinterpretsthemascharstrings.Now,inUTF-16,thecharactersetusedbyWindowswhenUnicodeisenabled,alltheASCIIcharactersarerepresentedasth
7、epairofbytes followedbytheASCIIvalue.Andsincethex86CPUislittle-endian,theorderofthesebytesareswapped,sothattheASCIIvaluecomesfirst,thenfollowedbyanullbyte.Andinacharstring,howisthestringusuallyterminated?Yep,byanullbyte.Soyourprogramseesabunchofstrings,eachonebytelong.
8、Ingeneral,youhavethreeoptionswhendoingWindowsprogramming:ExplicitlyuseUnicode(callwmain,andforeveryWindowsAPIf
此文档下载收益归作者所有