Hey, I know this isn't working because of the "i =toReverse.length();" in the for loop. I guess you can't use a function like this but how would I do what I'm trying to do?
1. Delete line 4, toReverse should be inside main and bob should be in reverse
2. Delete line 5, it should be inside reverse
3. You need to swap the first and last characters, then move one in and swap those, etc. or you can just reconstruct a new string from the old one:
And I wish I could use the rest of what you said but it's for an assignment and we haven't gone over any of that. Theres not any way to initialize i to the value of toReverse.length() without changing the rest is there?
You are very close, there are really only two changes you need to make for it work. Change cin >> toReverse
to getline(cin,toReverse);//using >> you wont get the whole string
And you need to subtract 1 from toReverse.length(), you're trying to read one to many characters. You should also follow notes 1 and 2 of LB's post.