字符串将 char* 与 LPCTSTR 连接起来
LPCTSTR Machine=L"Network\\Value";
char s[100]="Computer\\";
strcat(s,(const char*)Machine);
printf("%s",s);
在这里,我收到了输出 Computer\N 仅我期望像 Computer\Network\Value 这样的输出。 给出解决方案..
LPCTSTR Machine=L"Network\\Value";
char s[100]="Computer\\";
strcat(s,(const char*)Machine);
printf("%s",s);
Here i received output Computer\N only i expect output like Computer\Network\Value .
Give Solution for that..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
Machine 指向的字符串是一个 unicode 字符串,因此在字符“N”之后有一个 NULL 字符。 因此,如果您使用非 unicode 字符串连接,您将得到这样的输出。 你不应该像这样混合 unicode 和非 unicode 字符串。 你可以这样做:
The string pointed Machine is a unicode string and hence has one NULL character after the character 'N'. So if you use non-unicode string concatanation you will get the output like that. You should not mix the unicode and non-unicode strings like that. You can do it like this:
您尝试使用 Unicode 字符串来转换 ANSI 字符串。 那是行不通的。 要么将第一个字符串设置为 ANSI
,要么使用 MultiByteToWideChar() 转换第二个字符串。
You try to cancat an ANSI string with a Unicode string. That won't work. Either make the fisrt string ANSI
or convert the second one with MultiByteToWideChar().
纯C90:
Pure C90: