How to make a program that replaces each line of a file with its reverse
Peace be with you!
I am trying to make a program that replaces each line of a file with its reverse. The way I want to do it will involve reading and writing a text file (IO).
Of course the file will not be being written and read at the same time.
I want to do it in a such way I make random text (like "how are you") in a text file and then write codes that reverse it. If I run the program for the first time, I should get a reversed text (which is, for our example, "uoy era woh"). If I run it for the second time, I should get the original text.
Any idea of how to handle this?
I will appreciate your support.