#include
#include
//----------------------------------------------------------------------------------
void *str_l_trim( char *s )
//----------------------------------------------------------------------------------
// 去掉字符串左空格
{
int p = 0, k = 0;
if( strlen(s) == 0 )
return 0;
p = 0;
while ( s[p] == ' ' || s[p] == '\t' )
{
p++;
}
if( p == 0 )
return 0;
while( s[k] != '\0')
{
s[k++] = s[p++];
}
return 0;
}
//----------------------------------------------------------------------------------
void *str_r_trim( char *s )
//----------------------------------------------------------------------------------
// 去掉字符串右空格
{
int l = 0, p = 0;
l = strlen(s);
if( l == 0 )
return 0;
p = l - 1;
while ( s[p] == ' ' || s[p] == '\t' )
{
s[p--] = '\0';
if( p < 0 )
break;
}
return 0;
}
//----------------------------------------------------------------------------------
int main(void)
//----------------------------------------------------------------------------------
// 主函数
{
char *str = " wangchenxicool.cublog.cn ";
str_l_trim(str);
str_r_trim(str);
printf("%s", str);
getch();
return 0;
}
阅读(1680) | 评论(0) | 转发(0) |