The code you posted works, provided the string you pass to
Reverse()
is really a 0-terminated string! You should at the very least test
string
against nullptr, because that's pretty much the only thing that could cause an access violation:
void Reverse (char* string) {
if (string == nullptr)
return;
...
}
If that's not it (or even if it is!), learn to use a debugger, break at the point where you get the access violation, and check the current values of your variables.