- 1、题目
- 2、完整代码
- 3、截图
编写一个函数,利用指针实现对只包含字母和 * 号的字符串处理。将字符串中的开头连续的 * 号全部移到字符串的尾部
要求使用子函数:char* StrDel(char *s)
示例:
2、完整代码输入:***** st *** ring
输出:st *** ring *****
#include3、截图char *StrDel(char* s) { char b[81]; char* c, * d; c = s; int i = 0; while (*c == '*') { c++; } d = c; while (*c != ' ') { b[i] = *c; i++; c++; } int e = 0; while (s < d) { b[i] = *s; i++; s++; e++; } s = s - e; for (int j = 0; j < i; j++) { *s = b[j]; s++; } *s = ' '; } void main() { char s[81]; int n = 0; gets(s); StrDel(s); puts(s); }


![[C语言]使用指针将字符串中的开头连续的 * 号全部移到字符串的尾部 [C语言]使用指针将字符串中的开头连续的 * 号全部移到字符串的尾部](http://www.mshxw.com/aiimages/31/849409.png)
