Espacios de nombres
Variantes
Acciones

std::tmpnam

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

 
 
Entrada / salida de la biblioteca
I / O manipuladores
C-estilo I / O
Buffers
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(obsoleto)
Arroyos
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstracciones
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
File 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
Cadena de 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
Matriz 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(obsoleto)
ostrstream(obsoleto)
strstream(obsoleto)
Tipos
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
Error interfaz categoría
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-estilo I / O
Funciones
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Acceso a archivos
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.
Directo de entrada / salida
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
Entrada sin formato / salida
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.
Formato de entrada / salida
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.
Presentar posicionamiento
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
Gestión de errores
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
Las operaciones en los archivos
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 );
Crea un nombre de archivo único que no nombre un archivo existente en la actualidad, y la almacena en la cadena de caracteres apuntada por filename. La función es capaz de generar hasta TMP_MAX de nombres de archivo único, pero algunos o todos ellos pueden estar ya en uso, y por lo tanto no los valores adecuados de retorno .
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.

Contenido

[editar] Parámetros

filename -
puntero a la matriz de caracteres capaz de contener los bytes menos L_tmpnam, para ser usados ​​como un tampón resultado. Si NULL se pasa, un puntero a un buffer estático interno se devuelve .
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.

[editar] Valor de retorno

filename si filename no era NULL. De lo contrario un puntero a un buffer estático interno se devuelve. Si no hay ningún nombre de archivo adecuado puede ser generado, NULL se devuelve .
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.

[editar] Notas

Cuando se invoca con el argumento de puntero nulo, esta función modifica un objeto global. Si otro subproceso llama std::tmpnam con el argumento de puntero nulo al mismo tiempo, el comportamiento es indefinido debido a una raza datos .
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.
Aunque los nombres generados por std::tmpnam son difíciles de adivinar, es posible que un archivo con el mismo nombre creado por otro proceso entre los rendimientos std::tmpnam momento y el momento este programa intenta utilizar el nombre devuelto para crear un archivo. El std::tmpfile función estándar y la función POSIX mkstemp no tienen este problema .
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.

[editar] Ejemplo

#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

[editar] Ver también

crea y abre un temporal, auto-eliminación de archivos
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.

(función) [edit]
C documentation for tmpnam