char* removeMiddleStar(char *str) { if (!str) return str; char *p = str; for(; *p == ‘*‘; ++p); char *q = p; while(*++q != ‘\0‘); while(*--q == ‘*‘); for (char *k = p; *k != ‘\0‘; ++k) if ((k < q && *k != ‘*‘) || k >= q) *p++ = *k; *p = ‘\0‘; return str; }
删除 C 风格字符串中间的 '*'(不用库函数)
时间: 2024-09-29 01:56:06