#include <iostream>
#include <string>
using namespace std;
int main()
{
string character;
cout << "capacity: " <<character.capacity() << endl << "Input a sequence: \n";
getline(cin,character);
string reversestring;
int counter = 0;
for(int i = character.length() - 1; i >= 0; i--)
{
reversestring[counter++] = character[i];
}
cout << reversestring;
return 0;
}
messing around with a project above and I've hit an error I didn't expect. The program compiles fine, but whenever the user puts in there input I get the error "Debug Assertion Failed".
What can I do about that?
(I know there probably is problems with counter++ where it's at, but noticed a lot of C++ code put increments within the variable and liked the room it saves so messing around with that. Also I need to learn to use pointers, but that's something I plan on doing after I get it working this way.)