//去掉空格后的字符串长度
int trimSpaceStr01(char *p, int *mycount)
{int ret = 0;
int ncount = 0;
int i, j;
i = 0;
j = strlen(p) -1;
while (isspace(p[i]) && p[i] != '\0')
{
i++;
}
while (isspace(p[j]) && j>0 )
{
j--;
}
ncount = j - i + 1;
*mycount = ncount;
return ret;
}
//测试用例
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
void main()
{
char *p = " abcd ";
int ncount = 0;
int rev = 0;
rev = trimSpaceStr01( p, &ncount);
if(rev != 0)
{
printf("func trimSpaceStr01( ) err:%d;", ret);
}
printf("ncount:%d \n", ncount);
system("pause");}