#include #include void main() { // 0 = stdin, 1 = stdout, 2 = stderr char array[256]; int read_fd = open("./sample.txt", O_RDONLY); int write_fd = 2; // stdout int b = 0; // read the second half of the file by seeking to end // and rewinding to the midpoint. // fd offset base b = lseek(read_fd, 0, SEEK_END); b = lseek(read_fd, (b/2), SEEK_SET); do { b = read(read_fd, array, 255); write(write_fd, array, b); } while(b > 0); close(read_fd); }