◐ Shell
clean mode source ↗

std::strerror - cppreference.com

Da cppreference.com.

Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.

La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui.

Click here for the English version of this page

<metanoindex/>

<tbody> </tbody>

Elemento definito nell'header

<cstring>

char* strerror( int errnum );

versione testo Restituisce il codice di errore errnum. errnum di solito è acquisito dalla variabile errno, tuttavia la funzione accetta qualsiasi valore di int tipo. Il messaggio è specifica delle impostazioni locali.

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 stringa di byte restituito non deve essere modificato dal programma, ma può essere sovrascritto da una chiamata successiva alla funzione 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.

Parametri

errnum -

valore integrale riferimento a un errore codice

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.

Valore di ritorno

Puntatore a una stringa con terminazione null byte corrispondente al codice di errore 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.

Esempio

[edit]

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

Output:

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

Vedi anche