#include <stdio.h>
#include <string.h>
int cut_out_a_section_of_string(char str[], const int index_from, const int index_to) {
if (index_from < 0 || index_to < 0)
return -1;
int sectionlen = index_to - index_from;
int stringlen = strlen(str);
if (sectionlen < 0)
return -1;
memmove(str + index_from, str + index_from + sectionlen, stringlen - index_to);
str[stringlen - sectionlen] = '\0';
return 0;
}
int main(void)
{
// 01234567
char string[] = "C Programming";
cut_out_a_section_of_string(string, 4, 7);
printf("%s", string);
return 0;
}
/*
run:
C Pramming
*/