◐ Shell
clean mode source ↗

std::strerror - cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Definido no cabeçalho

<cstring>

char* strerror( int errnum );

Retorna a versão texto do código de erro errnum. errnum é geralmente adquirida a partir da variável errno, no entanto a função aceita qualquer valor de int tipo. A mensagem é específica para cada caso.

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.

A seqüência de byte retornado não deve ser modificado pelo programa, mas pode ser substituído por uma chamada subseqüente para a função 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.

Parâmetros

errnum -

valor. integrante referindo-se a um erro de 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.

Valor de retorno

Pointer. a um byte string terminada em nulo correspondente ao código de erro 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.

Exemplo

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

Saída:

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

Veja também

macros para condições normais POSIX-compatíveis erro

Original:

macros for standard POSIX-compatible error conditions

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(macro constante) [edit]