cfilemkstemp

Get the file name that was created by mkstemp()


Is it possible to get the file name (and path) from a call to mkstemp()? And if "yes", how?


Solution

  • From the mkstemp manual page:

    The last six characters of template must be "XXXXXX" and these are replaced with a string that makes the filename unique. Since it will be modified, template must not be a string constant, but should be declared as a character array.

    So you declare an array and pass it to the function, which will modify it, and then you have the filename in the array.