Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
langc
#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);
  }
}

...