今天在一国外网站上, 看到下面的代码, 觉得挺精简.
复制代码 代码如下:
char *tr ( char *s )
{
int i = 0;
int j = strlen ( s ) - 1;
int k = 0;
while ( isspace ( s[i] ) && s[i] != '\0' )
i++;
while ( isspace ( s[j] ) && j >= 0 )
j--;
while ( i <= j )
s[k++] = s[i++];
s[k] = '\0';
return s;
}