Espaces de noms
Variantes
Affichages
Actions

std::tmpfile

De cppreference.com
< cpp‎ | io‎ | c

 
 
D'entrée / sortie de bibliothèque
I / O manipulateurs
C-style I / O
Tampons
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf (obsolète)
Cours d'eau
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstractions
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
Fichier E / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
Chaîne I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
Tableau I / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream (obsolète)
ostrstream (obsolète)
strstream (obsolète)
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
Interface catégorie d'erreur
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category (C++11)
io_errc (C++11)
 
C-style I / O
Fonctions
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Déposer accès
Original:
File access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Entrée / sortie directe
Original:
Direct input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fread
fwrite
Entrée non formatée / sortie
Original:
Unformatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Mise en forme d'entrée / sortie
Original:
Formatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Fichier de positionnement
Original:
File positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ftell
fgetpos
fseek
fsetpos
rewind
Erreur de manipulation
Original:
Error handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
clearerr
feof
ferror
perror
Les opérations sur les fichiers
Original:
Operations on files
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
remove
rename
tmpfile
tmpnam
 
Defined in header <cstdio>
FILE* tmpfile();
Crée et ouvre un fichier temporaire avec unique nom de fichier généré automatiquement .
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.
Le fichier est ouvert en tant que fichier binaire pour mise à jour (comme par std::fopen avec mode d'accès "wb+"). Fichiers TMP_MAX au moins peut être ouverte pendant la durée de vie d'un programme (cette limite peut être partagé avec std::tmpnam et peut être davantage limitée par 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 le programme se ferme le fichier, par exemple en exécutant std::fclose, le fichier est automatiquement supprimé .
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 le programme se termine normalement (en appelant std::exit, de retour de main, etc), tous les fichiers qui ont été ouverts par std::tmpfile appelant sont automatiquement supprimés .
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 le programme se termine anormalement, il est défini par l'implémentation si ces fichiers temporaires sont supprimés .
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.

Sommaire

[modifier] Paramètres

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

[modifier] Retourne la valeur

Le flux de fichier associé ou NULL si une erreur s'est produite
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.

[modifier] Notes

Dans certaines implémentations (par exemple Linux), cette fonction crée en fait, s'ouvre, et immédiatement supprime le fichier du système de fichiers: tant qu'un descripteur de fichier ouvert dans un fichier supprimé est détenu par un programme, le fichier existe, mais comme il était supprimée, son nom ne figure pas dans n'importe quel répertoire, de sorte qu'aucun autre processus ne peut l'ouvrir. Une fois le descripteur de fichier est fermé, l'espace occupé par le fichier est récupéré par le système de fichiers .
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.

[modifier] Exemple

#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 name
    std::system("ls -l /proc/self/fd/3");
}

Résultat possible :

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

[modifier] Voir aussi

retourne un nom de fichier unique
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.

(fonction) [edit]
C documentation for tmpfile