Skip to content

Instantly share code, notes, and snippets.

@johnbartholomew
Last active January 1, 2016 10:29
Show Gist options
  • Save johnbartholomew/8132182 to your computer and use it in GitHub Desktop.
Save johnbartholomew/8132182 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
static const char MESSAGE[] = "Hello, world!\n";
int main(void) {
char fname[64];
int fd;
strcpy(fname, "/tmp/foo-XXXXXX");
fd = mkstemp(fname);
printf("Temp filename is '%s'\n", fname);
write(fd, MESSAGE, sizeof(MESSAGE) - 1);
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment