...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdio.h> #include <unistd.h> #include <fcntl.h> void open_some_file(const char *file) { int fd = open(file, O_CREAT | O_EXCL | O_RDONLYWRONLY); if (fd != -1) { FILE *f = fdopen(fd, "rw+w"); if (f != NULL) { printf("access granted.\n"); /* write to file */ if (fclose(f) != 0) { /* handle error */ } } if (close(fd) != 0) { /* handle error */ } } } |
...