Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::strerror

 

std::strerror is a function to convert the C-style error code (caused by C functions like std::fopen) to a std::string.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppStrerror.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += main.cpp
TARGET = CppStrerror

 

 

 

 

 

main.cpp

 

#include <cassert>  //For the assert macro
#include <cerrno>   //For the macro errno
#include <cstdio>   //For std::fopen
#include <cstring>  //For std::strerror
#include <string>

int main ()
{
  const FILE * const file = std::fopen("","r");
  assert(!file);
  assert(std::strerror(errno) == std::string("No such file or directory"));
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml