Good evening!
I have a C program that I have been working on for most of the week. I have gotten around 75% of it working. I'm stuck on the last part.
The question:
How do you read a file into memory, all into one buffer, reverse the contents of the buffer and then overwrite the buffer contents? I have a sample text file which I select in one of my menu options. I then use it in my option 4.
I have as my 4th option:
I believe I need to create and define the size of a buffer (max of 20,000 bytes), dump the contents of the chosen file into the buffer and then reverse contents. I close the file afterwards. If I choose to view the contents of the file I reversed (another option in my menu) I will see everything backwards. At least that is the plan.Code:else if (option == 4) { fp = fopen(filename, "r"); //open file //some other stuff inbetween fclose(fp); //close file }
On top of that, if no file is selected an error is displayed.
If anyone has a few suggestions, directions, examples or links to some really good tutorials on the subject of file manipulation I would greatly appreciate it.
Eternal Thanks!