错误:argument of type "char *" is incompatible with parameter of type "LPCWSTR"
2017-05-18 14:59
791 查看
方法一:
方法一只针对新手,在vs2010中修改编码格式:
右键工程——》
选择“properties”——》
选择“configuration properties”——》
再选择“general”——》
最后把“project default”下的“character set”修改为“use multi-byte character set”(默认为“use unicode character set”)
这样对新手来说,就省了很多类型显示转换的工夫。但是这对学习windows不好,因为这样无法理解windows编程的特性、字符格式的原理。有精力还是不要用方法一,多折腾下就好了,请看方法二和三,会学到很多东西的。学习编程都是这样,不要贪图闲逸,一定要不畏苦难,遇到困难要想方设法搞懂:
1.为什么会出现这种错误?
2.出现这种错误的解决方法?
3.哪种方法最好,为什么?
4.联想自己遇到过的类似问题,比较、思考、总结。
相信你这样子会走得更远。
方法二:
方法二要引入
才能使用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);
lpcwstr str4 = wch;
引用地址
方法一只针对新手,在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);
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"的解决方法
- "const wchar_t is incompatible with parameter of type "LPCSTR"
- angular Argument of type '"price"' is not assignable to parameter of type 'string[]'
- caffe cudnn出现错误: declaration is incompatible with "const char *cudnnGetErrorString(cudnnStatus_t)"
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleTh
- 错误提示:No enclosing instance of type A is accessible. Must qualify the allocation with an enclosing
- XCode中互相包含引起的"property with 'retain(or strong)' attribute must be of object type"错误与解决
- 处理编译错误"0" is an invalid value for the "DebugInformation" parameter of the "DCC" task.
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosi
- Titanium -- 运行app出现错误: TypeError: argument of type 'NoneType' is not iterable
- 验证参数传递引发的Java编译错误“No enclosing instance of type XXX is accessible" 及匿名内部类
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleT
- parameter "bandwidth_type" is not a formal parameter of instantiated module的解决方法
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleTh
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type SimpleT
- 闭包错误-Cannot invoke 'responseResult' with an argument list of type