How can i read txt from the tail ?

Hi all:

I use Seeeduino v3.0 , it is the same with Arduino ,

and i also include <SD.h>,

now i can create /read / write the File .

If I want to :

  1. read txt file from the tail ? (about 3 lines )

  2. write something from header of the file ...

  3. Quickly to count how many lines in the file and without "for loop" or "while loop"

how can i do ?

Can someone help me ?

It is key point in my thesis....plz...

  1. read txt file from the tail ? (about 3 lines )

The length of the file will allow you to seek() to the end of the file. Once there, you can seek backwards, one byte at a time, until you find the 4th end of record marker. Then, simply read three records.

  1. write something from header of the file ...

Then you wouldn't be reading from the end of the file...

  1. Quickly to count how many lines in the file and without "for loop" or "while loop"

Make all the record the same length. If you can't do that, you can't quickly count lines.

thank you for your answer ~

it's help me a lot !