回复 20 楼 TonyDeng
恩,谢谢!^_^
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> char str[] = "****dfs*hu*j"; int main(void) { size_t length = strlen(str); size_t index, pos; bool found = false; puts(str); for (index = 0, pos = 0; (index < length) || (pos < length); ++index) { if (str[index] != '*') { found = true; } if (found) { str[pos] = str[index]; if (index >= length) { str[pos] = '*'; } ++pos; } } puts(str); _getch(); return EXIT_SUCCESS; }