16,472
社区成员
发帖
与我相关
我的任务
分享
CString DelSeparator(CString inStr, CString spstr, int icut)
{
CString tmpstr="";
CString retStr, backStr;
int i;
spstr.MakeUpper();
if (spstr !="")
{
if (spstr=="SP")
{
spstr = " ";
}
do
{
i = inStr.Find(spstr);
if (i<0)
{
break;
}
tmpstr = tmpstr + inStr.Left(i);
inStr = inStr.Mid(i+1,inStr.GetLength()-i);
} while(1);
retStr = tmpstr + inStr;
backStr = retStr.Left(retStr.GetLength()-icut);
}
else
{
backStr = inStr.Left(inStr.GetLength()-icut);
}
return backStr;
}
void DelSeparator(char* inStr, char* spstr)
{
char* pStr;
char* tmpstr = inStr;
int dl = strlen(spstr);
int i,sl;
do
{
sl = strlen(tmpstr);
pStr = strstr(tmpstr,spstr);
if( NULL == pStr)
{
break;
}
sl -= (pStr-tmpstr);
tmpstr = pStr;
for(i=0; i<sl-dl; i++)
{
*(tmpstr+i) = *(pStr+dl+i);
}
*(tmpstr+i) = 0;
}while(1);
}
int _tmain(int argc, _TCHAR* argv[])
{
char str[] = "123456788901234567887340";
DelSeparator(str,"788");
return 0;
}
CString DelSeparator(CString inStr, CString spstr, int icut)
{
CString tmpstr="";
CString retStr, backStr;
int i;
spstr.MakeUpper();
if (spstr !="")
{
if (spstr=="SP")
{
spstr = " ";
}
do
{
i = inStr.Find(spstr);
if (i<0)
{
break;
}
//tmpstr = tmpstr + inStr.Left(i);
//inStr = inStr.Mid(i+1,inStr.GetLength()-i);
inStr.Replace(spstr,"");
} while(1);
retStr = inStr;
//retStr = tmpstr + inStr;
backStr = retStr.Left(retStr.GetLength()-icut);
}
else
{
backStr = inStr.Left(inStr.GetLength()-icut);
}
return backStr;
}