It is not true that mkstemp
does not let you know the temporary file name, try to compile and execute this program to see yourself:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char fn[] = "/tmp/fileXXXXXX";
int fd = mkstemp(fn);
char cmd[200];
int n = snprintf(cmd, sizeof(cmd), "ls -l %s\n", fn);
printf("snprintf=>%d\n sizeof(fn)=%d\n", n, sizeof(fn)); // extra info, see comments
printf("%s\n", cmd);
return system(cmd);
}
mkstemp
will replace the file name template in the buffer you pass to it with actual file name, you can do whatever you want with this buffer later on.