GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::strerror(3) C++ Standard Libary std::strerror(3)

std::strerror - std::strerror


Defined in header <cstring>
char* strerror( int errnum );


Returns a pointer to the textual description of the system error code errnum,
identical to the description that would be printed by std::perror().


errnum is usually acquired from the errno variable, however the function accepts any
value of type int. The contents of the string are locale-specific.


The returned string must not be modified by the program, but may be overwritten by a
subsequent call to the strerror function. strerror is not required to be
thread-safe. Implementations may be returning different pointers to static read-only
string literals or may be returning the same pointer over and over, pointing at a
static buffer in which strerror places the string.


errnum - integral value referring to a error code


Pointer to a null-terminated byte string corresponding to the errno error code
errnum.


POSIX allows subsequent calls to strerror to invalidate the pointer value returned
by an earlier call. It also specifies that it is the LC_MESSAGES locale facet that
controls the contents of these messages.


POSIX has a thread-safe version called strerror_r defined. Glibc defines an
incompatible version.

// Run this code


#include <iostream>
#include <cmath>
#include <cerrno>
#include <cstring>
#include <clocale>


int main()
{
double not_a_number = std::log(-1.0);
std::cout << not_a_number << '\n';
if (errno == EDOM) {
std::cout << "log(-1) failed: " << std::strerror(errno) << '\n';
std::setlocale(LC_MESSAGES, "de_DE.utf8");
std::cout << "Or, in German, " << std::strerror(errno) << '\n';
}
}


nan
log(-1) failed: Numerical argument out of domain
Or, in German, Das numerische Argument ist ausserhalb des Definitionsbereiches


displays a character string corresponding of the current
perror error to stderr
(function)
E2BIG, EACCES, ..., EXDEV macros for standard POSIX-compatible error conditions
(macro constant)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.