#include #include #include #include #include int main(int argc, char *argv[]) { int fd; char buf[50], buf2[] = "blah blah\n"; fd = open("temp", O_RDONLY); if (fd < 0) perror("Error reading temp"); else { read(fd, buf, 50); close(fd); } fd = open("temp", O_WRONLY); if (fd < 0) perror("Error writing temp"); else { write(fd, buf2, strlen(buf)); close(fd); } return 0; }