Is there a way to choose the point in a char array to insert a string without deleting any existing elements of the char array?i.e to insert a string anywhere in the char array
2 Answers
No. Arrays don't have methods to insert things into them.
STL containers have such methods. This is one of the many reasons why they are preferred to raw arrays.
If you still need to work with raw array for some reason, you can write a function which does what you need, using additional variable to perform the copy in it. But the returned result will be a different array, not your original one.
2 Comments
newprogramer
how do i index different characters of a string?
Daniel Daranas
@newprogramer See cplusplus.com/reference/string/string, in particular cplusplus.com/reference/string/string/at and cplusplus.com/reference/string/string/operator[].
std::string::insertis: en.cppreference.com/w/cpp/string/basic_string/insert . (You would probably use overload #2, 3, or 4 on that page for this.)