beginer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darko Lapanje

    beginer

    how can I write program who removes all ' ' from the string?

    dl


  • Alf P. Steinbach

    #2
    Re: beginer

    On Tue, 9 Sep 2003 15:52:16 +0200, "Darko Lapanje" <zre@hotmail.co m> wrote:
    [color=blue]
    >how can I write program who removes all ' ' from the string?[/color]

    There are ways that for an experienced programmer would be easier,
    but as a novice, translate to C++:


    1) Obtain string s from e.g. program arguments or user, or
    simply set it to a well-known test value like "steak brandy cigar".

    2) Set string t to empty.

    3) For each character position i in s, in ascending order:
    {
    Let c be character number i in s.
    If c is different from a space, then
    {
    Append c to the end of t.
    }
    }


    Comment

    • Russell Hanneken

      #3
      Re: beginer

      "Darko Lapanje" <zre@hotmail.co m> wrote in message
      news:bjkm2b$ocb $1@planja.arnes .si...[color=blue]
      > how can I write program who removes all ' ' from the string?[/color]

      There was actually a thread about this a couple of weeks ago:



      Regards,

      Russell Hanneken
      rhanneken@pobox .com


      Comment

      • Stuart Golodetz

        #4
        Re: beginer

        "Darko Lapanje" <zre@hotmail.co m> wrote in message
        news:bjkm2b$ocb $1@planja.arnes .si...[color=blue]
        > how can I write program who removes all ' ' from the string?
        >
        > dl[/color]

        s.erase(std::re move_if(s.begin (), s.end(),
        std::bind2nd(st d::equal_to<cha r>(), ' ')), s.end());

        HTH,

        Stuart.


        Comment

        Working...