The footer should update with current time and hour when a new Item added to the file.
Here is the sample file format,
ITEM1
ITEM2
06/07/2010 10:20:22 //footer line
The “item” has to append in the existing file, prior to the footer line, and the footer should be updated with new value.
I am having to variables, “item” and “time” which hold the respective values as string.
After adding a new item (ITEM3) the file looks like,
ITEM1
ITEM2
ITEM3
07/07/2010 17:20:12 //changed footer
Help me to acheive this.
Since the footer line is a static length…
Seek to the beginning of the footer line, write the new item over it followed by a newline, then write out the new footer.
(Note that this procedure is dangerous if you can’t guarantee that you will always write at least enough total bytes to overwrite the existing footer, but it looks like you have exactly that assurance here.)