33,311
社区成员
发帖
与我相关
我的任务
分享
#include <string>
#include <iostream>
using namespace std;
int main()
{
string quote1( "When lilacs last in the dooryard bloom'd" );
string quote2( "The child is in father of the man" );
string sentence;
sentence.assgin(quote2.c_str(), 13);
cout<< sentence <<endl;
return 0;
}
basic_string::assign
basic_string& assign(const E *s);
basic_string& assign(const E *s, size_type n);
basic_string& assign(const basic_string& str,
size_type pos, size_type n);
basic_string& assign(const basic_string& str);
basic_string& assign(size_type n, E c);
basic_string& assign(const_iterator first, const_iterator last);
Each member function replaces the sequence controlled by *this with the operand sequence, then returns *this.
In this implementation, if a translator does not support member template functions, the template:
template<class InIt>
basic_string& assign(InIt first, InIt last);
is replaced by:
basic_string& assign(const_iterator first, const_iterator last);