#include #include #include int filelength(int fileno) { struct stat sbuf; if(fstat(fileno, &sbuf) == -1) return 0; return sbuf.st_size; }