vs2005 int _tmain(int argc, _TCH…
来源:互联网 发布:淘宝新店东西怎么样 编辑:程序博客网 时间:2024/05/19 08:02
1#include "stdafx.h"
2
3int_tmain( int argc, _TCHAR * argv[])
4{
5
6 return 0;
7
8}
2
3int
5
6
7
8}
想当然,很好,很容易。试试列出命令的参数:
10}
11
运行结果竟然是这样的:
1
003A5210
“003A5210”是什么值?一开始就弄不懂了。
如果把_tmain函数变为:
1int main( int argc, char* argv[])
2{
3 cout << argc <<endl;
4 cout << argv[ 0] <<endl;
5 return 0;
6}
7
3
4
5
6}
7
运行结果正常:
D:\MyData\CSharp\Projects\test\Debug>test
1
d:\MyData\CSharp\Projects\test\Debug\test.exe
头大了。最后分别对两个函数运用断点中的反汇编看看,发现原来**argv竟然是wchar_t**,再翻弄了一下_TCHAR的声明:typedef wchar_t
一切明白了。要输出这个_TCHAR只能用cout的另一个版本:wcout。
为什么呢?原因很简单,因为他们都带了一个“w”在前面啊!
能正确输出_TCHAR*argv[]的版本:
10}
11
给出一个网上对_tmain的一个有用的定义:
1 #ifdef _UNICODE
2 #define _tmain wmain
3 #define _tWinMain wWinMain
4 #else
5 #define _tmain main
6 #define _tWinMain WinMain
7 #endif
3
4
5
6
7
- vs2005 int _tmain(int argc, _TCH…
- int main(int argc,char…
- int spi_write_then_read (struct …
- ch09_ex25 int Search(S…
- 【原创】Eclipse An int…
- int String互转
- 主函数main中变量(int argc…
- 主函数main中变量(int argc…
- __swi(0x00) void SwiHandle1(int …
- 转-int ,long , lo…
- int* 与 int&
- const int *pi与int&nbs…
- c++ MFC int 转换成 CString
- *(int *)a
- static int
- int getchar()
- OERR: ORA-3137 "TTC protocol int…
- Android中 int 和 String 互…
- ASCII表
- FTP命令
- FreeMarker常用语法
- RSA算法原理与例子
- VC和C++按行读取文本文件
- vs2005 int _tmain(int argc, _TCH…
- C++变量命名规则
- 金融自助设备WOSA/XFS规范介绍
- 电子邮件协议
- VC MFC SDI/MDI框架各部分指针获取…
- 分析MFC文档视图结构
- myeclipse中ssh开发1
- myeclipse中ssh开发2
- apache tomcat