一个删除字符数组中空格的功能,见代码
#include <stdio.h>
#include <string.h>
#include <memory.h>
void clearStringAllspace(char *s)
{
char *temp = s;
while (*temp) {
if(*temp != ' ' && *temp != '\t'){
//这里一定不能是||
*s++ = *temp;
}
temp++;
}
*s = '\0';
}
int main(int argc, char *argv[])
{
char buf[] = " abc edf ";
clearStringAllspace(buf);
printf("buf=%s=====\n", buf);
return 0;
}