On this page
  1. perror
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

perror

Prev: ferror | Up: stdio.h | Next: remove
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — perror
Tags: #public #prog #c #stdlib #stdio #tier/core


Include

#include <stdio.h>

Signature & Overview

void perror(const char *s);

Prints s, a colon, and the human-readable error message for current errno to stderr.

Notes & Pitfalls

Example

#include <stdio.h>

int main(void) {
    FILE *f = fopen("missing_demo_xyz", "r");
    if (!f) perror("open failed");
}

Linked from

Related notes