- char *trim(char *str)
- {
- char *p = str;
- while (*p == ' ' || *p == '\\t' || *p == '\\r' || *p == '\\n')
- p ++;
- str = p;
- p = str + strlen(str) - 1;
- while (*p == ' ' || *p == '\\t' || *p == '\\r' || *p == '\\n')
- -- p;
- *(p + 1) = '\\0';
- return str;
- }
- //该片段来自于http://www.codesnippet.cn/detail/090520133233.html
来源: http://www.codesnippet.cn/detail/090520133233.html