All languages

C

You're viewing a free preview. Sign in free to read every script.

Why this exists In Python or Java a failure raises an exception and jumps to a handler. In C nothing happens . fopen returns NULL, malloc returns NULL, read returns 1, and if you do not look, the program carries on with…

Error Handling in C: Return Codes, errno, strerror and the goto cleanup Pattern

C has no exceptions, so every failure is a return value you must check. Learn the return-code and errno conventions, why errno must be read immediately, and the single-exit goto cleanup pattern that stops leaks on error paths, proved with Valgrind.

Sign in free to read this script, along with the rest of the library.

Sign in free