Espacios de nombres
Variantes
Acciones

std::strerror

De cppreference.com
< cpp‎ | string‎ | byte
 
 
 
Cadenas de bytes terminadas en nulo
Funciones
Manipulación de caracteres
Conversiones a formatos numéricos
(C++11)(C++11)
(C++11)(C++11)
Manipulación de cadenas
Examinación de cadenas
Manipulación de memoria
Misceláneos
strerror
 
Definido en el archivo de encabezado <cstring>
char* strerror( int errnum );
versión Devuelve el texto del código de error errnum. errnum suele adquirirse a partir de la variable errno, sin embargo, la función acepta cualquier valor de tipo int. El mensaje es específico del entorno local .
Original:
Returns text version of the error code errnum. errnum is usually acquired from the errno variable, however the function accepts any value of type int. The message is locale-specific.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
La cadena de bytes devuelto no debe ser modificado por el programa, pero pueden ser sobrescritos por una llamada posterior a la función strerror .
Original:
The returned byte string must not be modified by the program, but may be overwritten by a subsequent call to the strerror function.
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

errnum -
valor integral se refiere a un error código
Original:
integral value referring to a error code
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

Puntero a una cadena terminada en cero byte correspondiente al código de error errnum .
Original:
Pointer to a null-terminated byte string corresponding to the error code errnum.
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 <cmath>
#include <cerrno>
#include <cstring>
 
int main()
{
    double not_a_number = std::log(-1.0);
    if (errno == EDOM) {
        std::cout << "log(-1) failed: " << std::strerror(errno) << '\n';
    }
}

Salida:

log(-1) failed: Numerical argument out of domain

[editar] Ver también

Macros para las condiciones de error estándar compatibles con POSIX.
(constante de macro) [editar]
Documentación de C para strerror