std::tmpfile
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <cstdio> | ||
FILE* tmpfile(); | ||
Crea e apre un file temporaneo con unico generato automaticamente file.
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.
You can help to correct and verify the translation. Click here for instructions.
Il file viene aperto come file binario per l'aggiornamento (come da std::fopen con modalità di accesso
"wb+"
). Almeno TMP_MAX file devono essere aperti durante il ciclo di vita di un programma (tale limite può essere condiviso con std::tmpnam e può essere ulteriormente limitata da 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.
You can help to correct and verify the translation. Click here for instructions.
Se il programma chiude il file, ad esempio eseguendo std::fclose, il file viene automaticamente cancellato.
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.
You can help to correct and verify the translation. Click here for instructions.
Se il programma termina normalmente (chiamando std::exit, di ritorno da main, ecc), tutti i file che sono stati aperti chiamando
std::tmpfile
vengono automaticamente eliminati.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.
You can help to correct and verify the translation. Click here for instructions.
Se il programma termina in modo anomalo, è definito dall'implementazione se questi file temporanei vengono eliminati.
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.
You can help to correct and verify the translation. Click here for instructions.
Indice |
[modifica]Parametri
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Valore di ritorno
Il flusso di file associato o NULL se è verificato un errore
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.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Note
In alcune implementazioni (ad esempio Linux), questa funzione crea in realtà, si apre, e subito cancella il file dal sistema di file: fino a quando un descrittore di file aperto in un file eliminato è detenuto da un programma, il file esiste, ma dato che era cancellato, il suo nome non compare in qualsiasi directory, in modo che nessun altro processo può essere aperto. Una volta che il descrittore di file viene chiuso, lo spazio occupato dal file viene recuperato dal filesystem.
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.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Esempio
#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");}
Possible output:
Hello lrwx------ 1 user group 64 Jun 27 00:28 /proc/self/fd/3 -> /tmp/tmpfXu58Zi (deleted)
[modifica]Vedi anche
restituisce un nome file univoco 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. (funzione) | |
C documentation for tmpfile |