64,578
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
using namespace std;
int main()
{
string aaa = "我是谁呀?";
int len = sizeof(aaa);
char *p = new char[len];
memcpy(p ,&aaa, len);
cout<<p<<endl;
system("pause");
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
int i = 333;
int len = sizeof(i);
char *p = new char[len];
memcpy(p ,&i, len);
cout<<p<<endl;
system("pause");
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
char *aaa = "我是谁呀?";
int len = strlen(aaa);
char *p = new char[len + 1];
p[len] = '\0';
memcpy(p ,aaa, len);
cout<<p<<endl;
system("pause");
return 0;
}