首页 > 代码库 > Algorithm delete some charactors from string

Algorithm delete some charactors from string

bool IsCharBelongString( IN const char* szIn, IN char ch )
{
    if (szIn)
    {
        while (*szIn)
        {
            if (ch == *szIn)
            {
                return true;
            }
            szIn++;
        }
    }
    return false;
}

void DeleteChar( IN char* szIn, IN const char* szDelete )
{
    if (szIn)
    {
        char* pStep1 = szIn;
        char* pStep2 = szIn;
        while (*pStep1)
        {
            if (!DIYIsCharBelongString(szDelete, *pStep1))
            {
                *pStep2++ = *pStep1;
            }
            pStep1++;
        }
        *pStep2 = 0;
    }
}

 

Algorithm delete some charactors from string