CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Posts
    2

    Shortening a string

    Heya, quick kind of silly question, what is the best way to shorten a string to get rid of asci characters below 90 for example?

    If I have a string such as "funny?" or "ending!", and I want to convert it to only "funny" or "ending" (basically just filter out all symbles). What is the best way to go about doing that? Thanks much.

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Shortening a string

    You can use the generic algorithm std::remove_if(), along with the erase() member function of std::string, or by setting the character at the iterator returned by remove_if() to '\0' for null terminated strings.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured