3个回答
展开全部
1. 包含以下头文件:
#include <algorithm>
2. 含义:
output_iterator copy( input_iterator start, input_iterator end, output_iterator dest );
The copy function copies the elements between start and end to dest. In other words, after copy has run,
*dest = *start
*(dest+1) = *(start+1)
*(dest+2) = *(start+2)
...
*(dest+N) = *(start+N)
The return value is the position in the destination range after the last element copied (i.e. dest+N+1). copy runs in linear time.
3. 程序举例:
For example, the following code uses copy to both copy the contents of one vector to another and to display the resulting vector:
vector<int> from_vector;
for( int i = 0; i < 10; i++ ) {
from_vector.push_back( i );
}
vector<int> to_vector(10);
copy( from_vector.begin(), from_vector.end(), to_vector.begin() );
cout << "to_vector contains: ";
copy( to_vector.begin(), to_vector.end(), ostream_iterator<int>( cout, " " ) );
cout << endl;
#include <algorithm>
2. 含义:
output_iterator copy( input_iterator start, input_iterator end, output_iterator dest );
The copy function copies the elements between start and end to dest. In other words, after copy has run,
*dest = *start
*(dest+1) = *(start+1)
*(dest+2) = *(start+2)
...
*(dest+N) = *(start+N)
The return value is the position in the destination range after the last element copied (i.e. dest+N+1). copy runs in linear time.
3. 程序举例:
For example, the following code uses copy to both copy the contents of one vector to another and to display the resulting vector:
vector<int> from_vector;
for( int i = 0; i < 10; i++ ) {
from_vector.push_back( i );
}
vector<int> to_vector(10);
copy( from_vector.begin(), from_vector.end(), to_vector.begin() );
cout << "to_vector contains: ";
copy( to_vector.begin(), to_vector.end(), ostream_iterator<int>( cout, " " ) );
cout << endl;
展开全部
一般是在字符串中用到strcpy()函数,头文件一般是#include<string.h>。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
size_type
copy(
char
*str,
size_type
num,
size_type
index
);
copy()函数拷贝自己的num个字符到str中(从索引index开始)。返回值是拷贝的字符数
copy(
char
*str,
size_type
num,
size_type
index
);
copy()函数拷贝自己的num个字符到str中(从索引index开始)。返回值是拷贝的字符数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询