Copy sequence of characters from string
Copies a substring of the current value of the string object into the array pointed by s. This substring contains the len characters that start at position pos.
s
The array shall contain enough storage for the copied characters.
If this is greater than the string length, it throws out_of_range.
Note: The first character in the string is denoted by a value of 0 (not 1).
// string::copy
#include <iostream>
#include <string>
int main ()
{
char buffer[20];
std::string str ("Test string...");
std::size_t length = str.copy(buffer,6,5);
buffer[length]='\0';
std::cout << "buffer contains: " << buffer << '\n';
return 0;
}