经拷贝后发现
unsigned char * 中的字符串是 "MIIGowYJ"
用memcpy拷贝到 char * 中变成 "M I I G o w Y J "
请问这个问题怎么解决使得 char * 中也是 "MIIGowYJ"
偶试了,没问题啊?
int main()
{
unsigned char stri[20] = "MIIGowYJ";
char arr[20];
memcpy(arr,stri, 19);
cout<<arr<<endl;
system("pause");
return 0;
}
结果: 输出: MIIGowYJ
是啊~~~
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
unsigned char ch[10] = {"MIIGowYJ"};
cout<<ch<<endl;
char ch1[20];
memcpy(ch1,ch,9);
cout<<ch1;
system("pause");
return 0;
}
不就可以了吗?