perror - C stdio.h

C examples for stdio.h:perror

Type

function

From


<cstdio>
<stdio.h>

Description

Print error message

Prototype

void perror ( const char * str );

Parameters.

ParameterDescription
str C string containing a custom message to be printed before the error message itself.

Return Value

none

Demo Code


#include <stdio.h>

int main ()// w  ww  .jav  a  2s.  c  o m
{
  FILE * pFile;
  pFile=fopen ("unexist.ent","rb");
  if (pFile==NULL){
      perror ("The following error occurred");
      return -1;
  }

  fclose (pFile);
  return 0;
}

Related Tutorials