string search and replace

This is a discussion on string search and replace within the C Programming forums, part of the General Programming Boards category; i want to searc a specific part in a string and change it for example (hello(world(how are you)today )are u ...

  1. #1
    Unregistered
    Guest

    string search and replace

    i want to searc a specific part in a string and change it for example


    (hello(world(how are you)today )are u fine)

    i want to change all are's with A

    result

    (hello(world(how A you)today )A u fine)

    how can i do such a thing?

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Well, you could start with using strstr() to find the first occurence of one string within another.... that might help.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Take cA that you don't replace things that A needed to form whole words.

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

  4. #4
    Unregistered
    Guest

    Angry

    i m sorry but i can not understand u

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Unregistered
    i m sorry but i can not understand u
    Look up how to use the function strstr(). In short, it finds the first occurence of one string within another. Understand how to use this function, and you will be on the way to solving your problem.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. vector search and replace
    By rahulsk1947 in forum C++ Programming
    Replies: 6
    Last Post: 06-04-2009, 10:13 PM
  2. search a string...
    By compile in forum C Programming
    Replies: 21
    Last Post: 01-16-2007, 04:51 AM
  3. Replies: 5
    Last Post: 05-25-2004, 05:36 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

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