Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#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);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment