User Tools

Site Tools


c:stdio.h:tmpfile

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdio.h:tmpfile [2013/01/22 22:02]
c:stdio.h:tmpfile [2024/02/16 01:05] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +
 +<code c>
 +    FILE *tmpfile(void);
 +</code>
 +
 +===== tmpfile =====
 +Creates temporary file which will be removed when closed or on normal program termination. \\
 +standard mode (mode "wb+")\\
 +Returns stream or NULL on failure.\\
 +
 +===== C Sourcecode Example =====
 +<code c>
 +/* 
 + * tmpfile example code
 + * http://code-reference.com/c/stdio.h/tmpfile 
 + */
 +
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +
 +int main ( void )
 +{
 +  FILE *stream = tmpfile();
 +  char c;
 +
 +  if( stream == NULL ) {
 +  perror("Error opening tmp file");
 + }
 +
 + fputs("Test 1234", stream);
 + rewind(stream);
 +
 +  while((c = fgetc(stream) ) != EOF) {
 +    printf("%c", c);
 +  }
 +
 + fclose (stream);
 +
 +  return 0;
 +}
 +
 +</code>
 +
 +==== output ====
 +    output: ./tmpfile
 +    Test 1234
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War

Impressum Datenschutz