CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Threaded View

  1. #9
    Join Date
    Apr 2010
    Posts
    20

    Re: Left trim a char*

    Code:
    std::string LeftTrim(const char * pString)
    {
    
        while (*pString == ' ')
        {
            ++pString;
        }
    
        std::string retValue(pString);
    
        return retValue;
    }
    
    std::string LeftTrim(const char * pString,const char * pCharSet)
    {
        bool bFound;
    
        while (true)
        {
            bFound = false;
    
            const char * pSet = pCharSet;
    
            while (bFound == false && *pSet != 0)
            {
                if (*pString == *pSet)
                {
                    ++pString;
                    bFound = true;
                }
                else
                {
                    ++pSet;
                }
            }
    
            if (bFound == false)
            {
                break;
            }
        }
    
        std::string strRetValue(pString);
    
        return strRetValue;
    }
    Last edited by CppCoder2010; August 24th, 2011 at 11:07 AM.

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