Thread: string help

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    134

    string help

    hi,
    i need to wire this function that replaces each occurence of ch1 in s with ch2. So if s is abcad, and ch1 is a, and ch2 is G, then the final output of s should be GbcGd.

    char s[ ], char ch1, char ch2....

    i tired a for loop but for some reason did not work....any other suggestions???

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Use the search button. This gets posted all the time. That aside, post your code, post your problem (be specific), and use code tags.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    void foo(char*b,char f,char r){char*p;for(p=b;p=strchr(p,f);*p++=r);}
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compare structures
    By lazyme in forum C++ Programming
    Replies: 15
    Last Post: 05-28-2009, 02:40 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM