CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 23 Jul 2025 01:34:02 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/cstdio/tmpfile/
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Jul 2025 01:34:03 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"80d9-xPVcxp46r9TfU1G+cer1Clelp04"
Content-Encoding: gzip
Creates a temporary binary file, open for update ("wb+" mode, see fopen for details) with a filename guaranteed to be different from any other existing file.
The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally. If the program terminates abnormally, whether the file is deleted depends on the specific system and library implementation.
On failure, NULL is returned.
This program creates a temporary file to store the lines entered by the user. When the user enters an empty line, the program rewinds the temporary file and prints its contents to stdout.
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<cstdio> (stdio.h)
functions
- clearerr
- fclose
- feof
- ferror
- fflush
- fgetc
- fgetpos
- fgets
- fopen
- fprintf
- fputc
- fputs
- fread
- freopen
- fscanf
- fseek
- fsetpos
- ftell
- fwrite
- getc
- getchar
- gets
- perror
- printf
- putc
- putchar
- puts
- remove
- rename
- rewind
- scanf
- setbuf
- setvbuf
-
snprintfC++11
- sprintf
- sscanf
- tmpfile
- tmpnam
- ungetc
- vfprintf
-
vfscanfC++11
- vprintf
-
vscanfC++11
-
vsnprintfC++11
- vsprintf
-
vsscanfC++11
objects
types
macro constants
function
<cstdio>
tmpfile
FILE * tmpfile ( void );
Open a temporary file
The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally. If the program terminates abnormally, whether the file is deleted depends on the specific system and library implementation.
Parameters
noneReturn Value
If successful, the function returns a stream pointer to the temporary file created.On failure, NULL is returned.
Example
|
|
This program creates a temporary file to store the lines entered by the user. When the user enters an empty line, the program rewinds the temporary file and prints its contents to stdout.
See also
- fopen
- Open file (function)
- tmpnam
- Generate temporary filename (function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us