编写函数 ltrim()去除字符串中的前导空格字符,并定义函数 rtrim()用去除字符串中后面连续的空格字符。
编写函数ltrim()去除字符串中的前导空格字符,并定义函数rtrim()用去除字符串中后面连续的空格字符。求救~用C++语言
2014-10-16 14:00
2014-10-16 14:06
2014-10-16 14:12
2014-10-16 14:17
程序代码:
#include<stdio.h>
void ltrim(char* s,char* t)
{
while(*s==0x20) s++;
while(*s!='\0')
{
*t=*s;
t++;
s++;
}
}
int main()
{
char c[]=" abcdefg!";
char d[100]={'\0'};
ltrim(c,d);
printf("%s\n",d);
return 0;
}

2014-10-16 14:29
2014-10-16 14:57

2014-10-16 15:04
2014-10-16 15:06
2014-10-16 15:06