---
name: "explain_fopen_or_die"
section: "3"
platform: "linux"
package: "libexplain-dev"
version: "1.4.D001-16"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/explain_fopen_or_die"
---

# explain\_fopen\_or\_die(3)

open file and report errors

## NAME

explain\_fopen\_or\_die - open file and report errors

## SYNOPSIS

\#include \<libexplain/fopen.h\>

FILE \*explain\_fopen\_or\_die(const char \*pathname, const char \*flags);

## DESCRIPTION

The **explain\_fopen\_or\_die**() function opens the file whose name is the string pointed to by pathname and associates a stream with it. See [*fopen*(3)](/fopen/3.md) for more information.

This is a quick and simple way for programs to constitently report file open errors in a consistent and detailed fahion.

## RETURN VALUE

Upon successful completion **explain\_fopen\_or\_die** returns a *FILE* pointer.

If an error occurs, **explain\_fopen** will be called to explain the error, which will be printed onto *stderr*, and then the process will terminate by calling `exit(EXIT_FAILURE)`.

## SEE ALSO

- [*fopen*(3)](/fopen/3.md)

  stream open functions

- [*explain\_fopen*(3)](/explain_fopen/3.md)

  explain [*fopen*(3)](/fopen/3.md) errors

- [*exit*(2)](/exit/2.md)

  terminate the calling process

## COPYRIGHT

libexplain version 1.4\
 Copyright (C) 2008 Peter Miller

## AUTHOR

Written by Peter Miller \<pmiller@opensource.org.au\>
