Print last 10 lines of file or stdin with read write and lseek [closed]
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 months ago . I'm working on an implementation of the tail function and I'm only supposed to use read() , write() and lseek() for I/O, and so far I have this: int printFileLines(int fileDesc) { char c; int lineCount = 0, charCount = 0; int pos = 0, rState; while(pos != -1 && lineCount < 10) { if((rState = read(fileDesc, &c,