If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Revert a string code is not working

I created a .txt file that I called in.txt. It has the letters: a b c d e.
I put it in the same folder as the c++ code below. I was hoping that I after I compile and run the code, the in.txt file would read: e d c b a.
Unfortunately, it doesn't. Even when I give the ofstream file another name, it does not create another text file. Any idea on what could be causing this?

Re: Revert a string code is not working

There are 2 errors with this program. One should have produced a compiler warning about a variable being used without having been initialised. The other is purely program logic. However, if you debug your code using a debugger these would be easy to spot. As VictorN said, you must debug code!

Incidentially, if all you want to do is reverse some text held in a file why have the reverse function? Once you have read it into the array why not just write it back looping the array from end to start?

Re: Revert a string code is not working

My compiler did not warn me about any variable being used without having been initialized. What is this variable?
Also, when I run the code or when I click on the debug button, the console pops out empty with only a cursor that seems to stagnate. I don't know what that means.