I'm trying to add a space behind capital letters of a string for example. "ILikeBananas" would turn into "I like bananas"
I've tried using a while loop, isupper, and .insert((i-1), " "). I noticed that it would work if it were i+1 however that would give me the wrong output.
void fixedInput(string &userInput) {
int i = 1;
while (userInput[i]) {
if (isupper(userInput[i])) {
userInput.insert((i-1)," ");
tolower(userInput[i]);
}
i++;
}
}
with (i-1) there is no output