Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/tmpfile.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/tmpfile.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/tmpfile.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/tmpfile.html on line 8
Create a temporary file
#include <stdio.h>
FILE* tmpfile( void );
FILE* tmpfile64( void );
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The tmpfile() and tmpfile64() functions create a temporary file and opens a
corresponding FILE stream. The file is
automatically removed when it's closed or when the program terminates.
The file is opened in update mode (as in
fopen()'s w+ mode).
If the process is killed between file creation and unlinking, a permanent
file may be left behind.
|
When a stream is opened in update mode, both reading and writing
may be performed. However, writing may not be followed by reading without an
intervening call to the
fflush() function, or to a
file-positioning function
(fseek(),
fsetpos(),
rewind()).
Similarly, reading may not be followed by writing without an
intervening call to a file-positioning function, unless the read
resulted in end-of-file. |
A pointer to the stream of the temporary file, or NULL
if an error occurs
(errno
is set).
- EACCESS
- The calling process doesn't have permission to create the temporary file.
- EMFILE
- The calling process already has already used OPEN_MAX
file descriptors.
- ENFILE
- The system already has the maximum number of files open.
- EROFS
- The filesystem for the temporary file is read-only.
#include <stdio.h>
#include <stdlib.h>
static FILE *TempFile;
int main( void )
{
TempFile = tmpfile();
…
fclose( TempFile );
/* The temporary file will be removed when we exit. */
return EXIT_SUCCESS;
}
tmpfile() is
ANSI,
POSIX 1003.1;
tmpfile64() is
Large-file support
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
fopen(),
fopen64(),
freopen(),
freopen64(),
tempnam(),
tmpnam()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/t/tmpfile.html on line 185
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/t/tmpfile.html on line 185