string manipulation

This is a discussion on string manipulation within the Linux Programming forums, part of the Platform Specific Boards category; Hi, any help on this would be appreciated. I need to insert a string some where inside of another string. ...

  1. #1
    SPEKTRUM
    Guest

    Question string manipulation

    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.

  2. #2
    B26354 Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Hi Spektrum,

    memmove() comes to mind.

    Cheers,
    Jason Deckard

  3. #3
    SPEKTRUM
    Guest
    thanks!

  4. #4
    junior member mix0matt's Avatar
    Join Date
    Aug 2001
    Posts
    144
    if you're using C++, you can use the string Datatype. it provides an insert method....

    Code:
    #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;
    }
    THIS IS NOT JUST A CHRONICLING OF THINGS WE HAVE DONE IN THE PAST BUT OUR RISE TO POWER.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 07:02 AM
  2. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 07:52 PM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 10:19 AM
  4. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  5. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21