#include<iostream> using namespace std; int main() { string str1 = "geeksforgeeks is for geeks"; string str2 = "geeksforgeeks is for geeks"; char ch1[100]; char ch2[100]; cout<<str1.size()<< endl << endl; str1.copy(ch1,23,0); str2.copy(ch2,24,0); cout << ch1 << endl << endl; cout << ch2 << endl << endl; return 0; } The length of string is 26, when I tried to copy more than 23 characters, it is showing weird behavior (printing random character in the last) Here is the output of the above program
26 geeksforgeeks is for ge geeksforgeeks is for gee£qí╜∙⌂