Espacios de nombres
Variantes
Acciones

std::tmpfile

De cppreference.com
< cpp‎ | io‎ | c
 
 
 
 
Definido en el archivo de encabezado <cstdio>
FILE* tmpfile();
Crea y abre un archivo temporal con el único nombre de archivo generado automáticamente .
Original:
Creates and opens a temporary file with unique auto-generated filename.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
El archivo se abre como un archivo binario de actualización (como por std::fopen con modo de acceso "wb+"). Mínimo archivos TMP_MAX puede ser abierta durante el tiempo de vida de un programa (este límite puede ser compartida con std::tmpnam y puede ser limitado por FOPEN_MAX)
Original:
The file is opened as binary file for update (as by std::fopen with access mode "wb+"). At least TMP_MAX files may be opened during the lifetime of a program (this limit may be shared with std::tmpnam and may be further limited by FOPEN_MAX)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si el programa se cierra el archivo, por ejemplo, mediante la ejecución de std::fclose, el archivo se elimina automáticamente .
Original:
If the program closes the file, e.g. by executing std::fclose, the file is automatically deleted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si el programa termina normalmente (llamando std::exit, al regresar de main, etc), todos los archivos que se abrieron llamando std::tmpfile también se eliminan automáticamente .
Original:
If the program terminates normally (by calling std::exit, returning from main, etc), all files that were opened by calling std::tmpfile are also automatically deleted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si el programa termina de forma anormal, es definido por la implantación si estos archivos temporales se eliminan .
Original:
If the program terminates abnormally, it is implementation-defined if these temporary files are deleted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar]Parámetros

(Ninguno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Valor de retorno

La secuencia de archivo asociado o NULL si ha ocurrido un error
Original:
The associated file stream or NULL if an error has occurred
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Notas

En algunas implementaciones (por ejemplo, Linux), esta función crea realmente, se abre e inmediatamente elimina el archivo del sistema de archivos: mientras un descriptor de fichero abierto a un archivo borrado se lleva a cabo por un programa, el archivo existe, pero ya que era eliminado, su nombre no aparece en ningún directorio, por lo que ningún otro proceso puede abrirlo. Una vez que el descriptor de fichero está cerrada, el espacio ocupado por el archivo sea reclamado por el sistema de ficheros .
Original:
On some implementations (e.g. Linux), this function actually creates, opens, and immediately deletes the file from the file system: as long as an open file descriptor to a deleted file is held by a program, the file exists, but since it was deleted, its name does not appear in any directory, so that no other process can open it. Once the file descriptor is closed, the space occupied by the file is reclaimed by the filesystem.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Ejemplo

#include <iostream>#include <cstdio>#include <cstdlib>   int main(){ FILE* tmpf = std::tmpfile();std::fputs("Hello, world", tmpf);std::rewind(tmpf);char buf[6];std::fgets(buf, sizeof buf, tmpf);std::cout<< buf <<'\n';   // Linux-specific method to display the tmpfile namestd::system("ls -l /proc/self/fd/3");}

Posible salida:

Hello lrwx------ 1 user group 64 Jun 27 00:28 /proc/self/fd/3 -> /tmp/tmpfXu58Zi (deleted)

[editar]Ver también

devuelve un nombre de archivo único
Original:
returns a unique filename
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función)[editar]
Documentación de C para tmpfile
close