Fliping a string
Is there like a function that flips strings backwards?
If not, how would you go about fliping a string?
i was thinking something like this:
The only problem with that is that I keep getting an error:
for(int i = str.size(), z = 0; i > 0; i--, z++)
str2[z] = str[i];
Why! It only happens with Visual Studio 8 2005.
Debug Assertation Failed!
Expression: string subscript out of range
For more information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
There are a couple of problems with your code.
The main one is that the index string.size() is one to high.
edit: removed bull........
and yes there is a standard way
reverse( str.begin(), str.end() );