PDA

View Full Version : string manipulation



SPEKTRUM
01-25-2002, 08:36 PM
Hi, any help on this would be appreciated.

I need to insert a string some where inside of another string. Example:

My String.

My goofy String.

I need to insert 'goofy' inside of 'My String'. see what I mean?

Thanks.

Deckard
01-25-2002, 10:11 PM
Hi Spektrum,

memmove() comes to mind.

Cheers,

SPEKTRUM
01-25-2002, 10:38 PM
thanks!

mix0matt
01-26-2002, 11:41 AM
if you're using C++, you can use the string Datatype. it provides an insert method....


#include <iostream>

using std::cout;
using std::endl;

#include <string>

using std::string;

int main ()
{
string s1 = "My String";

s1.insert (3, "Goofy "); // insert "Goofy " at position 3
cout << s1 << endl;
return 0;
}