C++ strerror() Function
You are Here:
C++ strerror()
The strerror()
function translates the error code to a suitable string that describes the error.
This function is defined in <cstring> and <cerrno> header file.
Example
C++ Compiler
#include <iostream>
#include <cstring>
#include <cerrno>
using namespace std;
int main()
{
FILE *fp;
fp = fopen("no-file.txt", "r");
if(fp == NULL)
cout << "Error: " << strerror(errno);
return 0;
}
Output
Error: No such file or directory
Syntax
char *strerror(int errnum)
Parameter Values
Value | Type | Explanation |
---|---|---|
errno | Required | Specifies the error code. |
Return Value
Value | Explanation |
---|---|
Address | Returns a pointer to the error string describing error errnum. |
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on C++ with examples for quick and easy learning.
We are working to cover every Single Concept in C++.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.