Hi all, I'm new to system programming. I wanted to read from a file into a buffer (say, buf[BUFSIZ]), from the end to the beginning. For example, if the file contains "Hello", then the buffer will contain "olleH". I know lseek() will reposition the opened file offset. I just tried lseek(fd, -6, 2), but the result is still "Hello". I don't know why. Please help, thank you very much!
philipghu
Recommended Answers
Jump to PostEven though what you want to do makes no sense,
1- Use
lseek()
to get to the end of the file.
2-lseek()
back one character
3- read the character
4- repeat 2&3 until you get to the beginning of the file
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.