change a string

This is a discussion on change a string within the C Programming forums, part of the General Programming Boards category; Hello there, I want to know if anybody knows about a function to change a string for another one. If ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    33

    change a string

    Hello there,

    I want to know if anybody knows about a function to change a string for another one. If not, I suppose i would have to work in it. Thank you very much.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Do you mean to replace a substring? Or to alter a current string (ie, strcpy()) ?

    Have a look through here to see if you can find a function that does what you want:

    http://en.wikipedia.org/wiki/String.h

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    33
    the problem is for example if a have the string:

    (pointer)line->"I have no mouth but ..."

    and I want to change the word mouth by "yes" for example. the result should be:

    line->"I have no yes but ..."

    Thank you for your help.

  4. #4
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    A little search on this forum for "substring replace" gave me immediately two very interesting threads:

    Substr
    Str_replace function

    Both contain explanations as well as working functions.

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    33
    Thank you! I will see those articles!

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    37
    Quote Originally Posted by KONI View Post
    A little search on this forum for "substring replace" gave me immediately two very interesting threads:

    Substr
    Str_replace function

    Both contain explanations as well as working functions.
    very good.. dude... As the saying goes.

    "You feed a hungry man with a fish you feed him only that day..
    You teach him how to fish ... you feed him everyday... " :-)

  7. #7
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    I'm Jesus, I feed entire nations with only one fish.

  8. #8
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    I thought it was:

    Light a fire for a man and he'll be warm for a day.
    Light a man on fire and he'll be warm the rest of his life.
    If you understand what you're doing, you're not learning anything.

  9. #9
    Registered User
    Join Date
    Mar 2007
    Posts
    28
    Quote Originally Posted by KONI View Post
    I'm Jesus, I feed entire nations with only one fish.
    then give me fish : ), I'm starvin ...

    by the way, before posting a new theard, it's really more beneficial way looking at old posts, for instance today when I was searching a particular topic I found a theard from 2002 and it complety solved my problem...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How properly inherit from template?
    By 6tr6tr in forum C++ Programming
    Replies: 118
    Last Post: 04-25-2008, 04:30 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  4. Again Character Count, Word Count and String Search
    By client in forum C Programming
    Replies: 2
    Last Post: 05-09-2002, 11:40 AM

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