replace a substring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nityagopikrishnan
    New Member
    • Sep 2008
    • 2

    replace a substring

    how do i replace a substring.....e g hello world ...replace hello with hai an d you get hai world
  • freddukes
    New Member
    • Sep 2008
    • 18

    #2
    Are you using char * or std::strings?

    In std::strings there are several helpful class functions, see here. That site should be all you need for std::strings.

    If you are using char* then you'll have to use iterators to do all of your work.

    -freddukes

    Comment

    • curiously enough
      New Member
      • Aug 2008
      • 79

      #3
      Just use a 2-dimensional array of charachters filled with the words of the string, then fill another empty string as you like with these words(with spaces between them of course).

      Comment

      • Man4ish
        New Member
        • Mar 2008
        • 151

        #4
        Originally posted by curiously enough
        Just use a 2-dimensional array of charachters filled with the words of the string, then fill another empty string as you like with these words(with spaces between them of course).
        Use replace function of string class.

        Manish

        Comment

        Working...