Temporary files If all you're worried about is creating a temporary file, there are some handy helpers in C: int mkstemp( template ) Generates unique temporary file name and opens file with O_EXCL and 0600 perms. FILE* tmpfile() Generates unique temporary file name and opens file with O_EXCL and 0600 perms Immediately deletes file after creation. More portable than mkstemp. Functions not to use (vulnerable to race conditions) char* tempnam( dir, prefix ) char* tmpnam( NULL ) char* mktemp( template )