How to remove the character at a given index from a string in C?

memmove can handle overlapping areas, I would try something like that (not tested, maybe +-1 issue)

char word[] = "abcdef";  
int idxToDel = 2; 
memmove(&word[idxToDel], &word[idxToDel + 1], strlen(word) - idxToDel);

Before: "abcdef"

After: "abdef"

Leave a Comment