String

Método Copy

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.

// 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;
}
La salida sería:
buffer contains: string