删除字符串中指定n个字符.c 372 B

12345678910111213141516171819202122232425
  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 < len - num; j++) {
  7. s[j] = s[j + num];
  8. }
  9. s[len - num] = '\0';
  10. }
  11. int main() {
  12. char s[50];
  13. scanf("%s", s);
  14. int i, num;
  15. scanf("%d %d", &i, &num);
  16. del(s, i, num);
  17. printf("%s\n", s);
  18. return 0;
  19. }