#include #include #include #include #include int main(int argc, char** argv) { int fd = open("test.txt", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); if (fd < 0) { fprintf(stderr, "return from open %d\n", fd); return 1; } char txt[] = "Hello World\n"; int r = write(fd, txt, sizeof(txt)); if (r != sizeof(txt)) { fprintf(stderr, "return from write unexpected -- %d -- %s\n", r, strerror(errno)); return 1; } close(fd); return 0; }