I have a char array filled with some characters. Let\'s say I have \"HelloWorld\" in my char array. (not string. taking up index of 0 to 9)
What I\'m trying to do is ins
You need to start the inner loop from strlen(ch) + 1
, not strlen(ch) - 1
, because you need to move the NULL-terminator to the right one place as well. Remember that strlen
returns the length of the string such that string[strlen(string)] == '\0'
; you can think of strlen
as a function for obtaining the index of the NULL-terminator of a C-string.