How would you insert it without overwriting the character?
I tried using
char temp;
temp = x;
x = y;
y= temp;
think but I guess it doesn't work that way.
So any ideas how I can add a space without disrupting the text or punctuation?
Thanks.
Edit:
My problem is I'm trying do word count but count punctuation as well. And char reads '.' fine if there's a space.
Aka.
"I like bananas . Heh ."
This would be "6" words. when including punct.
but my problem is I can't separate the space so I just have, "I like bananas. Heh."
I know.
I'm asking how you would add it in though because I can't separate the string because I'm reading it from a file. Well, even so, I don't know how to split a string.
It doesn't matter whether you're reading it from a file or not - if you can get it into a std::string or even a sadistic character array, you can manipulate it and get the various parts of it with eh corresponding substr function(s).
I, being unfamiliar with all the functionality that strings offer, would say put your text into a character array, and then have the program read through the array, counting a new word every time it encounters a whitespace or punctuation. Following that rule, "I like bananas." would count as four words.