Working of errno in C++
The errno works as the explain below:
Initially at the beginning of the program, the errno
is set to zero and it changes when any error occurs.- If a function call fails it sets
errno
, then we check its value. There is no change in the valueerrno
if no errors occur.
How to use errno in C++?
In C++ errno
is a preprocessor macro that is used for error indication and reporting errors that occur during a function call. It contains error codes so if a call to a function fails somehow then the errno is set to a value that corresponds to the error.
errno is defined in the header file <cerrno>
i
n C++.
Contact Us