How to read file in reverse order?
-
I wand to read file form end to the start of the file... byte by byte... can anyone suggest me or provide me any sample code that helps me...??????:confused::confused: thanks in advance... Savcejana Sukinobavanthu Ashok.
You could do it with a for loop, find the length of the file in bytes (using a while loop or otherwise) then do a for loop but backwards for(int i=FileLength; i>=0; i -=1) { //Read the file i number of bytes }
-
I wand to read file form end to the start of the file... byte by byte... can anyone suggest me or provide me any sample code that helps me...??????:confused::confused: thanks in advance... Savcejana Sukinobavanthu Ashok.
Why do you need to do this? I would suggest reading the file into a buffer, and then reversing that buffer. It'll be much faster this way.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Why do you need to do this? I would suggest reading the file into a buffer, and then reversing that buffer. It'll be much faster this way.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
or reading the file and inserting in the buffer at the beginning instead of at the end.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
or reading the file and inserting in the buffer at the beginning instead of at the end.
Maximilien Lincourt Your Head A Splode - Strong Bad
Maximilien wrote:
or reading the file and inserting in the buffer at the beginning...
Which is how files are normally read. :confused:
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Maximilien wrote:
or reading the file and inserting in the buffer at the beginning...
Which is how files are normally read. :confused:
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
I don't know, if I have to read a file in order, I will read a line ( for example, a text file ) and add the newly read line at the end of my "buffer". if I want to read the file in reverse order, I might read the file in order and then sort internally what I have read, or try to read the file in reverse (from the end ) and add to the buffer at the end.
Maximilien Lincourt Your Head A Splode - Strong Bad