Must you use char arrays (C strings), or can you just use std::string?
The problem here is that in your code, string and str_r are just pointers, and since you never allocate an array for them to point to, you're just accessing and writing to some random piece of memory that you probably shouldn't be tampering with.
On a side note, implementing a to_string function is a lot easier if you use a std::stringstream....
I am restricted to use "pure C++"; even STL is restricted. I'm just using std::cout for show the output. I know that I should allocate the memory (dynamic memory allocation), so I'll create an array with an int function that looks as strlen(char*) (my implementation) and intlen(int). Any suggestion?