删除字符串中指定n个字符——6-06.c 370 B

123456789101112131415161718192021
  1. #include <stdio.h>
  2. #include <string.h>
  3. void del(char s[], int i, int num) {
  4. int len = strlen(s);
  5. int j;
  6. for (j = i - 1; j + num < len; j++) {
  7. s[j] = s[j + num];
  8. }
  9. s[len - num] = '\0';
  10. }
  11. int main() {
  12. char s[51];
  13. int i, num;
  14. scanf("%s", s);
  15. scanf("%d %d", &i, &num);
  16. del(s, i, num);
  17. printf("%s\n", s);
  18. return 0;
  19. }