User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdio.h:tmpnam

Table of Contents

tmpnam

    char *tmpnam(char *str);

Assigns to s (if s non-null) and returns unique name for a temporary file. Unique name is returned for each of the first TMP_MAX invocations.

C Sourcecode Example

/* 
 * tmpnam example code
 * http://code-reference.com/c/stdio.h/tmpnam 
 */
 
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
 
int main ( void ) 
{
FILE *tmpstream;
char *tmpfile;
 
tmpfile = tmpnam(NULL);
tmpstream= fopen(tmpfile, "w");
 
if ( tmpstream == NULL) {
  perror("Error opening tmp stream");
}
 
fputs("Test for tmpnam", tmpstream);
 
rename(tmpfile, "test.txt");
fclose(tmpstream);
return 0;
 
}

content of test.txt after executing ./tmpnam

Test for tmpnam

output

  ./tmpnam 

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdio.h/tmpnam.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz