Replace a character in a string.

Discussion in 'C++' started by Venkat, Dec 15, 2003.

  1. Venkat

    Venkat Guest

    Greetings,

    I got a string like this str = {1234-4543-6453-ACBD-AFEB} now i need to have
    an output like str = 1234-4543-6453-ACBD-AFEB, basically i want to remove
    the characters
    '{' and '}'.

    here is the code....

    vector<string> Temp;

    //Fill the elements in Temp
    ........................
    .........................

    //Read the elements from Temp

    for (int l = 0; l < Temp.size(); ++l)
    {
    std::string str= Temp[l].c_str();

    }


    Now str outputs the values with character '{' and '}' i need it to output
    values without these characters.


    Pl Help.


    Regards,
    Venkat
     
    Venkat, Dec 15, 2003
    #1
    1. Advertising

  2. Venkat

    lallous Guest

    "Venkat" <> wrote in message
    news:1071469855.463813@sj-nntpcache-5...
    > Greetings,
    >
    > I got a string like this str = {1234-4543-6453-ACBD-AFEB} now i need to

    have
    > an output like str = 1234-4543-6453-ACBD-AFEB, basically i want to remove
    > the characters
    > '{' and '}'.
    >
    > here is the code....
    >
    > vector<string> Temp;
    >
    > //Fill the elements in Temp
    > .......................
    > ........................
    >
    > //Read the elements from Temp
    >
    > for (int l = 0; l < Temp.size(); ++l)
    > {
    > std::string str= Temp[l].c_str();
    >
    > }
    >
    >
    > Now str outputs the values with character '{' and '}' i need it to output
    > values without these characters.
    >
    >
    > Pl Help.
    >
    >
    > Regards,
    > Venkat


    std::string newstr = s.substr(1, s.length()-2);

    --
    Elias
     
    lallous, Dec 15, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brand Bogard

    8 bit character string to 16 bit character string

    Brand Bogard, May 25, 2006, in forum: C Programming
    Replies:
    8
    Views:
    748
    those who know me have no need of my name
    May 28, 2006
  2. herman
    Replies:
    5
    Views:
    7,633
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=
    Aug 30, 2007
  3. Alun
    Replies:
    3
    Views:
    4,572
    Masudur
    Feb 18, 2008
  4. Victor
    Replies:
    3
    Views:
    141
    Victor
    Sep 12, 2003
  5. Bart Vandewoestyne
    Replies:
    8
    Views:
    762
    Bart Vandewoestyne
    Sep 25, 2012
Loading...

Share This Page