Skip to content

Instantly share code, notes, and snippets.

@joshwilliams
Created August 19, 2020 15:39
Show Gist options
  • Save joshwilliams/51adb08ca1a31cf63bb6748048bd4858 to your computer and use it in GitHub Desktop.
Save joshwilliams/51adb08ca1a31cf63bb6748048bd4858 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
int errnum, fd;
int main(int argc, char *argv[]) {
if ( argc == 2 ) {
fd = open(argv[1], O_CREAT);
if (fd == -1) {
fprintf(stderr, "Error opening %s: %s (%d)\n", argv[1], strerror(errno), errno);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment