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