Skip to main content

Debugging for C Programmings

C debugging is the use of tools to find bugs that the language does not report on its own. gdb lets you step through code and inspect memory, valgrind and AddressSanitizer detect leaks and invalid accesses, and compiler warnings catch mistakes early. These tools are essential because C errors often show up far from their cause.

Stage: Debugging and Systems · Part of the C Programming roadmap · Last reviewed 19 November 2026

What to learn in Debugging

Debugging interview questions

What usually causes a segmentation fault?

It occurs when a program accesses memory it is not allowed to, commonly by dereferencing a NULL or dangling pointer, writing past an array, or overflowing the stack through deep recursion. Running under gdb shows the faulting line.

How do valgrind and AddressSanitizer differ?

Valgrind runs your unmodified binary on a virtual CPU and reports leaks and invalid memory use, but it slows the program a lot. AddressSanitizer instruments the code at compile time, is much faster, and catches many errors, though it needs a rebuild.

Where Debugging fits in the C Programming roadmap

Debugging belongs to the Debugging and Systems stage (advanced level). Go deeper.

Back to the full C Programming roadmap