Espaces de noms
Variantes
Affichages
Actions

std::tmpnam

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>
char* tmpnam( char* filename );
Crée un nom de fichier unique qui ne nomme pas un fichier existant actuellement, et le stocke dans la chaîne de caractères pointée par filename. La fonction est capable de générer jusqu'à TMP_MAX des noms de fichiers uniques, mais tout ou partie d'entre eux peut-être déjà en cours d'utilisation, et donc pas les valeurs de retour appropriés .
Original:
Creates an unique filename that does not name a currently existing file, and stores it in the character string pointed to by filename. The function is capable of generating up to TMP_MAX of unique filenames, but some or all of them may already be in use, and thus not suitable return values.
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

filename -
pointeur vers le tableau de caractères pouvant contenir au moins L_tmpnam octets, pour être utilisé comme un buffer de résultat. Si NULL est passé, un pointeur vers une mémoire tampon interne statique est retourné .
Original:
pointer to the character array capable of holding at least L_tmpnam bytes, to be used as a result buffer. If NULL is passed, a pointer to an internal static buffer is returned.
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

filename si filename n'était pas NULL. Sinon, un pointeur vers un tampon interne statique est renvoyé. Si aucun fichier approprié peut être générée, est renvoyé NULL .
Original:
filename if filename was not NULL. Otherwise a pointer to an internal static buffer is returned. If no suitable filename can be generated, NULL is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Notes

Lorsqu'il est appelé avec l'argument de pointeur nul, cette fonction modifie un objet global. Si un autre thread appelle std::tmpnam avec l'argument de pointeur NULL dans le même temps, le comportement est indéfini due à une race de données .
Original:
When called with null pointer argument, this function modifies a global object. If another thread calls std::tmpnam with null pointer argument at the same time, the behavior is undefined due to a data race.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Bien que les noms générés par std::tmpnam sont difficiles à deviner, il est possible qu'un fichier portant ce nom est créé par un autre processus entre les rendements std::tmpnam instant et le moment de ce programme tente d'utiliser le nom renvoyé pour créer un fichier. Le std::tmpfile fonction standard et la fonction POSIX mkstemp n'ont pas ce problème .
Original:
Although the names generated by std::tmpnam are difficult to guess, it is possible that a file with that name is created by another process between the moment std::tmpnam returns and the moment this program attempts to use the returned name to create a file. The standard function std::tmpfile and the POSIX function mkstemp do not have this problem.
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 <string>
int main()
{
    std::string name1 = std::tmpnam(nullptr);
    std::cout << "temporary file name: " << name1 << '\n';
 
    char name2[L_tmpnam];
    if(std::tmpnam(name2))
        std::cout << "temporary file name: " << name2 << '\n';
}

Résultat possible :

temporary file name: /tmp/fileDjwifs
temporary file name: /tmp/fileEv2bfW

[modifier] Voir aussi

crée et ouvre un temporaire, auto-suppression du fichier
Original:
creates and opens a temporary, auto-removing file
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 tmpnam