C++中strcpy系列的函数是不是只适用数组,string类型的不适用???

string类有没有类似于strcpy系列的函数??????

第1个回答  2010-07-25
strcpy不适用于string类,string类中要完成复制只要用+,如
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
string s1("Hello ");
string s2("World");
string s3;
s3=s1+s2;
cout<<s3<<endl;
//strcmp(s1,s2);
//cout<<s1<<endl;
return 0;
}

输出就是Hello World
第2个回答  2010-07-25
strcpy是char型数组拷贝函数。
如果是string类型的拷贝直接调用拷贝构造函数就可以了。
或者用memcoy((unsigned char*)pDes,(unsigned char*)strData,sizeof(strData))
第3个回答  2010-07-25
strcpy

Copies one string to another.

应该也是实用的
第4个回答  2010-07-25
有,你去下载一个C语言库函数查询工具吧,想查就查本回答被提问者采纳
相似回答