tmpnam : tmpnam « stdio.h « C Tutorial






ItemValue
Header filestdio.h
Declarationchar *tmpnam(char *name);
Functiongenerates a unique filename. *name should be at least L_tmpnam characters long. L_tmpnam is defined in .
Returnthe unique temp name on success or a null pointer on error.


  1. The function can be called up to TMP_MAX times.
  2. TMP_MAX is defined in , and it will be at least 25.

Display three unique temporary filenames

#include <stdio.h>

  int main(void)
  {
    char name[40];
    int i;

    for(i=0; i<3; i++) {
      tmpnam(name);
      printf("%s ", name);
    }
    return 0;
  }








22.38.tmpnam
22.38.1.tmpnam