- 论坛徽章:
- 9
|
char *trimbody(char *str)
{
if (str)
{
char *lpSrc = str, *lpDest = str;
while (1)
{
char* lpCh = strchr(lpSrc, ' ');
if (lpCh == NULL)
{
size_t szToCopy = strlen(lpSrc) + 1;
if (lpDest != lpSrc)
memmove(lpDest, lpSrc, szToCopy);
break;
}
else
{
size_t szToCopy = lpCh - lpSrc;
if ((lpDest != lpSrc) && (szToCopy != 0))
memmove(lpDest, lpSrc, szToCopy);
lpSrc += szToCopy + 1;
lpDest += szToCopy;
}
}
}
return str;
}
|
回观一下,发现我错了,赶紧改之……
[ 本帖最后由 w_anthony 于 2010-1-12 22:18 编辑 ] |
|