A. C語言中去掉空格問題
/*去除字元串右邊空格*/
void
vs_strrtrim(char
*pstr)
{
char
*ptmp
=
pstr+strlen(pstr)-1;
while
(*ptmp
==
'
')
{
*ptmp
=
'\0';
ptmp--;
}
}
/*去除字元串左邊空格*/
void
vs_strltrim(char
*pstr)
{
char
*ptmp
=
pstr;
while
(*ptmp
==
'
')
{
ptmp++;
}
while(*ptmp
!=
'\0')
{
*pstr
=
*ptmp;
pstr++;
ptmp++;
}
*pstr
=
'\0';
}