std::tmpfile
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
definiert in Header <cstdio>
|
||
FILE* tmpfile(); |
||
Erstellt und öffnet eine temporäre Datei mit einzigartigen Auto-generated Dateinamen .
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.
Die Datei wird als binäre Datei für die Aktualisierung (wie std::fopen mit Zugang Modus
"wb+"
) eröffnet. Mindestens TMP_MAX Dateien während der Laufzeit eines Programms geöffnet werden (Dieser Anteil kann mit std::tmpnam geteilt werden und können weiter begrenzt durch 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.
Wenn das Programm die Datei schließt, z. B. durch Ausführen std::fclose, wird die Datei automatisch gelöscht .
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.
Wenn das Programm normal beendet (durch Aufruf std::exit, der Rückkehr von main, etc), werden alle Dateien, die durch Aufrufen
std::tmpfile
geöffnet wurden auch automatisch gelöscht .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.
Wenn das Programm beendet wird, ist es durch die Implementierung definiert, wenn diese temporären Dateien gelöscht werden .
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.
Inhaltsverzeichnis |
[Bearbeiten] Parameter
(None)
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.
[Bearbeiten] Rückgabewert
Die zugehörige Datei Stream oder NULL, wenn ein Fehler aufgetreten ist
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.
[Bearbeiten] Notes
In einigen Implementierungen (zB Linux), wird diese Funktion tatsächlich schafft, öffnet und sofort löscht die Datei aus dem Dateisystem: Solange ein offener Dateideskriptor zu einer gelöschten Datei von einem Programm gehalten wird, existiert die Datei, aber da war es gelöscht, nicht seinen Namen nicht in einem beliebigen Verzeichnis auf, so dass kein anderer Prozess kann es zu öffnen. Sobald die Datei-Deskriptor geschlossen ist, wird der Raum durch die Datei belegt durch das Dateisystem zurückgefordert .
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.
[Bearbeiten] Beispiel
#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"); }
Possible output:
Hello lrwx------ 1 user group 64 Jun 27 00:28 /proc/self/fd/3 -> /tmp/tmpfXu58Zi (deleted)
[Bearbeiten] Siehe auch
gibt einen eindeutigen Dateinamen 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. (Funktion) | |
C documentation for tmpfile
|