错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
来源:互联网 发布:制作图片音乐的软件 编辑:程序博客网 时间:2024/05/16 17:52
方法一:
方法一只针对新手,在vs2010中修改编码格式:
右键工程——》
选择“Properties”——》
选择“Configuration Properties”——》
再选择“General”——》
最后把“Project Default”下的“Character Set”修改为“Use Multi-Byte Character Set”(默认为“Use Unicode Character Set”)
这样对新手来说,就省了很多类型显示转换的工夫。但是这对学习windows不好,因为这样无法理解windows编程的特性、字符格式的原理。有精力还是不要用方法一,多折腾下就好了,请看方法二和三,会学到很多东西的。学习编程都是这样,不要贪图闲逸,一定要不畏苦难,遇到困难要想方设法搞懂:
1.为什么会出现这种错误?
2.出现这种错误的解决方法?
3.哪种方法最好,为什么?
4.联想自己遇到过的类似问题,比较、思考、总结。
相信你这样子会走得更远。
方法二:
方法二要引入 #include<tchar.h>,才能使用TEXT等进行转换
- LPCWSTR str1 = TEXT("Hello");
- LPCWSTR str2 = L"Hello";
- LPCWSTR str3 = _T("Hello");
方法三:
这种是针对使用变量来存储字符串的解决方法。
- const char* ch = "Hello";
- WCHAR wCh[6];
- MultiByteToWideChar( 0,0, ch, 5, wCh, 6); //MultiByteToWideChar函数用法请看MSDN
- LPCWSTR str4 = wCh;
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 错误:argument of type "char *" is incompatible with parameter of type "LPCWSTR"
- angular Argument of type '"price"' is not assignable to parameter of type 'string[]'
- 【Ionic】Argument of type“**Service”is not assignable to parameter of type 'RebirthHttp'.
- Cannot initialize a parameter of type 'char **' with
- 使用cuDNN5编译py-faster-rcnn错误:cudnn.hpp(126): error: argument of type "int" is incompatible ...
- Sending 'ccColor4B' (aka 'struct _ccColor4B') to parameter of incompatible type 'CIColor *'错误
- Sending 'ViewController' to Parameter of Incompatible Type 'id<xxxDelegate>'
- warning: passing argument 2 of 'request_irq' from incompatible pointer type导致的中断申请失败和
- warning: passing argument 2 of 'request_irq' from incompatible pointer type导致的中断申请失败和
- No parameter name specified for argument of type
- Initializing 'AppDelegate *__strong' with an expression of incompatible type
- 闭包错误-Cannot invoke 'responseResult' with an argument list of type
- Swift*Cannot invoke 'jsonObject' with an argument list of type
- Win API中SendMessage和PostMessage的区别
- 英利9160访问Ubuntu的nfs
- 云计算仿真工具中文注释CloudletScheduler.java
- 三大WEB服务器对比分析(apache ,lighttpd,nginx)
- 如何MFC实现计算一个文件夹的大小
- 错误argument of type "char *" is incompatible with parameter of type "LPCWSTR"的解决方法
- 学习笔记之C#类的构造方法
- 云计算仿真工具中文注释CloudletSchedulerDynamicWorkload.java
- C#(winform)文本框只能输入数字和退格键和小数点
- Android自定义属性
- WINDOWS消息大全
- 云计算仿真工具中文注释CloudletSchedulerSpaceShared.java
- 理解C++中复杂的指针声明
- ==与equals的区别,try......catch......finally,final、finally、 finalize的区别