#include<protos.h> #include<io.h> void main() { clrscr(); int fd=open("C:\\text.txt",O_RDONLY); if(fd==-1) { printf("FIle does not exists...."); return ; } char c; int i=0; lseek(fd,-1L-i,SEEK_END); do { read(fd,&c,1); printf("%c",c); i++; } while( lseek(fd,-1L-(i),SEEK_END)!=0); read(fd,&c,1); printf("%c",c); getch(); }
How to run it?
$gcc file.c \
$./a.out