Namensräume
Varianten
Aktionen

std::tmpnam

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

 
 
Input / Output-Bibliothek
I / O-Manipulatoren
C-style I / O
Puffern
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(veraltet)
Streams
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstraktionen
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
Datei-I / 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
String 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
Array 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(veraltet)
ostrstream(veraltet)
strstream(veraltet)
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
Fehler Kategorie Schnittstelle
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
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Dateizugriff
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.
Direkte Eingabe / Ausgabe
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
Unformatierte Eingang / Ausgang
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.
Formatierte Eingabe / Ausgabe
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.
Datei Positionierung
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
Fehlerbehandlung
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
Operationen auf Dateien
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 );
Erstellt einen eindeutigen Dateinamen, die nicht zu nennen ist eine aktuell vorhandene Datei und speichert sie in der Zeichenkette, auf die filename. Die Funktion ist in der Lage bis zu der einzigartigen Dateinamen TMP_MAX, aber einige oder alle von ihnen können bereits verwendet werden, und somit nicht geeignet Rueckgabewerte .
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.

Inhaltsverzeichnis

[Bearbeiten] Parameter

filename -
Zeiger auf den Zeichen-Array in der Lage ist, die mindestens L_tmpnam Bytes, um als Ergebnis Puffer verwendet werden. Wenn NULL übergeben wird, wird ein Zeiger auf eine interne statische Puffer zurückgegeben .
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.

[Bearbeiten] Rückgabewert

filename wenn filename nicht NULL. Andernfalls wird ein Zeiger auf einen internen statischen Puffer zurückgegeben. Wenn keine geeignete Dateinamen erzeugt werden kann, wird zurückgegeben 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.

[Bearbeiten] Notes

Wenn sie mit Null-Zeiger-Argument aufgerufen, modifiziert diese Funktion ein globales Objekt. Wenn ein anderer Thread ruft std::tmpnam mit Null-Zeiger-Argument in der gleichen Zeit, ist das Verhalten undefiniert aufgrund eines Data Race .
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.
Obwohl die Namen von std::tmpnam generiert schwer zu erraten sind, ist es möglich, dass eine Datei mit diesem Namen von einem anderen Prozess zwischen den Moment std::tmpnam Renditen und dem Moment, dieses Programm versucht, um den zurückgegebenen Namen verwenden, um eine Datei zu erstellen erstellt. Die Standard-Funktion std::tmpfile und die POSIX-Funktion mkstemp nicht über dieses Problem .
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.

[Bearbeiten] Beispiel

#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';
}

Possible output:

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

[Bearbeiten] Siehe auch

erstellt und öffnet eine temporäre, automatische Entfernen Datei
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.

(Funktion) [edit]
C documentation for tmpnam