如何将char * string复制到WCHAR []字符串 [英] How to Copy char* string to WCHAR[] string

查看:145
本文介绍了如何将char * string复制到WCHAR []字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我写了一个简单的程序。


WCHAR NameBuffer [512];

char * str1 =" ; c:\\Program Files \\test.txt" ;

swprintf(NameBuffer,L"%s",str1);


我试图调试这个程序。在Namebuffer处的值正在显示一些

垃圾值,如square symbol.how来解决此问题。


请任何人帮我...

谢谢,

Manjunath.M

解决方案

Manjunath.M写道:




我写了一个简单的程序。


WCHAR NameBuffer [512];



什么是WCHAR?


char * str1 =" c:\\Program Files \\test.txt" ;

swprintf(NameBuffer,L"%s",str1);



上面看起来像语法错误。
< blockquote class =post_quotes>
我试图调试这个程序。在Namebuffer处的值正在显示一些

垃圾值,如square symbol.how来解决此问题。



请发布真实的程序,上面肯定不是''它。


-

Ian Collins。


2月22日,11:53 am,Ian Collins< ian-n ... @ hotmail.comwrote:


Manjunath.M写道:




我写了一个简单的程序。


WCHAR NameBuffer [512];



什么是WCHAR?


char * str1 =" c:\\Program Files \\test.txt" ;

swprintf(NameBuffer,L"%s",str1);



上面看起来像语法错误。


我试图调试这个程序。在Namebuffer处的值显示一些

垃圾值,如square symbol.how来解决这个问题。



请发贴真实的节目,上面肯定不是。


-

伊恩柯林斯。



int main()

{

WCHAR NameBuffer [100];

char * str1 =" c:\\Program Files \\test.txt"

swprintf(NameBuffer,L"%s",str1);

printf("%s",NameBuffer);

返回0;

}

这是用C编写的程序。 br />


Manjunath.M写道:


>> ;
请发布真实的节目,上面肯定不是。



请修剪签名。


int main()

{

WCHAR NameBuffer [100];

char * str1 =" ; c:\\Program Files \\test.txt"

swprintf(NameBuffer,L"%s",str1);

printf(" %s",NameBuffer);

返回0;

}


这是程序员用C写的。



它看起来不像:


cc xc

" x.c",第12行:未定义的符号:WCHAR

" x.c",第12行:语法错误之前或之后:NameBuffer

" ; x.c",第14行:语法错误之前或之后:swprintf

" x.c",第15行:警告:隐式函数声明:printf

" ; x.c",第15行:未定义的符号:NameBuffer


-

Ian Collins。


Hi,
I wrote a simple program.

WCHAR NameBuffer[512];
char * str1 = "c:\\Program Files\\test.txt" ;
swprintf(NameBuffer,L"%s",str1);

I tried to debug this program. value at "Namebuffer" is showing some
garbage values like square symbol.how to resolve this.

please can any one help me ...
Thanks,
Manjunath.M

解决方案

Manjunath.M wrote:

Hi,
I wrote a simple program.

WCHAR NameBuffer[512];

What is WCHAR?

char * str1 = "c:\\Program Files\\test.txt" ;
swprintf(NameBuffer,L"%s",str1);

The above looks like syntax error.

I tried to debug this program. value at "Namebuffer" is showing some
garbage values like square symbol.how to resolve this.

Please post the real program, the above certainly isn''t it.

--
Ian Collins.


On Feb 22, 11:53 am, Ian Collins <ian-n...@hotmail.comwrote:

Manjunath.M wrote:

Hi,
I wrote a simple program.

WCHAR NameBuffer[512];


What is WCHAR?

char * str1 = "c:\\Program Files\\test.txt" ;
swprintf(NameBuffer,L"%s",str1);


The above looks like syntax error.

I tried to debug this program. value at "Namebuffer" is showing some
garbage values like square symbol.how to resolve this.


Please post the real program, the above certainly isn''t it.

--
Ian Collins.

int main()
{
WCHAR NameBuffer[100];
char *str1 ="c:\\Program Files\\test.txt"
swprintf(NameBuffer,L"%s",str1);
printf("%s",NameBuffer);
return 0;
}
This is the program written in C.


Manjunath.M wrote:

>>
Please post the real program, the above certainly isn''t it.

Please trim signatures.

int main()
{
WCHAR NameBuffer[100];
char *str1 ="c:\\Program Files\\test.txt"
swprintf(NameBuffer,L"%s",str1);
printf("%s",NameBuffer);
return 0;
}

This is the program written in C.

It doesn''t look like it:

cc x.c
"x.c", line 12: undefined symbol: WCHAR
"x.c", line 12: syntax error before or at: NameBuffer
"x.c", line 14: syntax error before or at: swprintf
"x.c", line 15: warning: implicit function declaration: printf
"x.c", line 15: undefined symbol: NameBuffer

--
Ian Collins.


这篇关于如何将char * string复制到WCHAR []字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆