Thread: string manipulation

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    string manipulation

    hi friends
    m trying to write a code that would:

    1)find the occurance of characters
    '!', '$' '?' '.' ',' etc.
    2)Also write a function to
    replace all odd occurance of '?' to '.'.

    related with this is the other question-
    find all the occurance of all the abusive words in a file and replace them with
    '####' by looking up in a master_table

    can u guys help me out?
    thanks

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    define: help
    define: string

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    How far have you managed to get with your program(s)? Hint : The C++ <string> library has alot of built-in string manipulation functions such as find()

  4. #4
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    You should look:
    www.cppreference.com
    under string section!
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    You using std::string, or C style strings (char *, char[])? finding all occurrences

    Code:
    for ( parameters go through length of string )
    {
      if ( this element of the string == '!' etc ) output found something at this location!;
    }
    replace function
    Code:
    function replace ( your string )
    {
      you could recycle some code from above
      {
         if ( found element is a ? ) change that element to something else!
      }
    }
    the last one, just expand the above two code snippets. The above is pseudo code. To point you in the right direction.

    This thread stinks of homework!

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    2
    i cant find find () and remove()
    where are they ?in which header files??
    Last edited by apsonline; 08-29-2006 at 11:45 PM.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    You should have payed attention in class.

    http://www.cppreference.com/cppstring/index.html
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    Quote Originally Posted by apsonline
    i cant find find () and remove()
    where are they ?in which header files??
    My first reply in this thread was a big clue..

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, 06:02 AM
  2. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  3. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. string manipulation
    By SPEKTRUM in forum Linux Programming
    Replies: 3
    Last Post: 01-26-2002, 11:41 AM