如果函数的形参是字符常量,可以加上const char a="1111"‘’ 告诉用户是数据常量
如果将一个字符串的空格给去掉,通过将指针的的地址赋值给另外的指针,进行移位,如
#includevoid del_space(char * s1);int main(int argc, char *argv[]){ char s[] = " h a sdf g "; puts(s); del_space(s); puts(s); return 0;}void del_space(char * s1) { char * s2; s2 = s1; while (*s1) { if (*s1 == ' '){ s1++; } else { *s2 = *s1; s1++; s2++; } } *s2 = '\0';}