congdantoancau

Convert string to char*

Dec 6th, 2017
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. // string::copy
  2. #include <iostream>
  3. #include <string>
  4.  
  5. int main ()
  6. {
  7.   char buffer[20];
  8.   std::string str ("Test string...");
  9.   //string.copy(char*, length, begin);
  10.   std::size_t length = str.copy(buffer,6,5);
  11.   buffer[length]='\0';
  12.   std::cout << "buffer contains: " << buffer << '\n';
  13.   return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment