C examples for stdio.h:tmpfile
function
<cstdio> <stdio.h>
Open a temporary file for update ("wb+" mode) with a unique filename.
The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally.
FILE * tmpfile ( void );
none
On success, the function returns a stream pointer to the temporary file.
On failure, NULL is returned.
#include <stdio.h> #include <string.h> int main ()/*from w ww .j a v a 2 s . co m*/ { char buffer [256]; FILE * pFile; pFile = tmpfile (); do { if (!fgets(buffer,256,stdin)) break; fputs (buffer,pFile); } while (strlen(buffer)>1); rewind(pFile); while (!feof(pFile)) { if (fgets (buffer,256,pFile) == NULL) break; fputs (buffer,stdout); } fclose (pFile); return 0; }