C gives you nothing but a compiler and responsibility. These questions check whether a candidate truly understands pointers, memory and undefined behaviour.
Hiring a C developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.
Junior C interview questions
0–2 years
Fundamentals.
What is a pointer?
A variable holding a memory address; dereferencing it accesses the value there. Pointers enable indirection and dynamic memory.
Confuses a pointer with the value it points to.
What is the difference between the stack and the heap?
The stack holds automatic, scope-bound locals and is fast; the heap is manually managed dynamic memory via malloc/free.
Thinks all variables live in the same place.
What does malloc return and what must you check?
A pointer to uninitialised heap memory, or NULL on failure — which you must check before using.
Uses the result of malloc without a NULL check.
What is the difference between = and ==?
= assigns; == compares. Accidentally using = in a condition is a classic bug.
Writes if (x = 5) unintentionally.
What is an array’s relationship to a pointer?
An array name decays to a pointer to its first element in most expressions, but they are not identical (e.g. sizeof).
Thinks arrays and pointers are fully interchangeable.
What is the difference between char *s and char s[]?
A pointer to (often read-only) string data vs a mutable array holding a copy; modifying a string literal is undefined.
Modifies a string literal and crashes.
What does const do?
Marks data as non-modifiable through that name, documenting and enforcing intent, including for pointer targets.
Ignores const-correctness.
What is the difference between ++i and i++?
Both increment; pre-increment yields the new value, post-increment the old — relevant in expressions.
Cannot predict the value in an expression.
Mid-level C interview questions
2–5 years
Memory and pointers.
What is a memory leak and how does it occur?
Heap memory allocated but never freed because its pointer is lost or forgotten; long-running programs degrade.
Never frees allocated memory.
What is a dangling pointer?
A pointer to memory that has been freed or gone out of scope; dereferencing it is undefined behaviour.
Uses a pointer after free.
What is a buffer overflow and why is it dangerous?
Writing past an array’s bounds, corrupting memory and a classic security vulnerability.
Copies into a fixed buffer without bounds checking.
What is the difference between malloc, calloc and realloc?
malloc allocates uninitialised memory, calloc zero-initialises, realloc resizes an existing block.
Assumes malloc zeroes memory.
What is a function pointer and where is it used?
A pointer to executable code, used for callbacks, dispatch tables and plugin-like designs.
Never uses them and duplicates dispatch logic.
What is the difference between pass by value and by pointer?
C passes by value; to mutate a caller’s variable you pass its address (a pointer).
Expects a function to modify a passed-by-value argument.
What is sizeof and a common pitfall?
A compile-time operator giving a type/object’s size; a pitfall is sizeof on a pointer expecting the pointed-to array size.
Uses sizeof(ptr) to get array length.
What is the difference between a shallow and deep copy of a struct?
Copying a struct copies pointer members by value (shared targets); a deep copy duplicates what they point to.
Copies a struct with pointers and gets double-frees.
Senior C interview questions
5+ years
Undefined behaviour and systems.
What is undefined behaviour and why does it matter?
Operations the standard leaves undefined (out-of-bounds access, signed overflow, use-after-free); compilers may do anything, and it’s a top source of bugs and exploits.
Treats a program that happens to work as correct despite UB.
How do you debug memory errors in C?
Tools like Valgrind and AddressSanitizer detect leaks, invalid accesses and use-after-free that are otherwise silent.
Debugs memory corruption with print statements alone.
What is memory alignment and struct padding?
Types must sit at aligned addresses, so the compiler pads structs; misunderstanding it causes wasted space and portability bugs.
Assumes struct size equals the sum of member sizes.
What are volatile and restrict for?
volatile tells the compiler a value may change outside program flow (hardware/signals); restrict promises non-aliasing to enable optimisation.
Uses volatile as a concurrency primitive.
How do you write portable C?
Avoid undefined and implementation-defined behaviour, don’t assume type sizes or endianness, and use fixed-width types where needed.
Assumes int is always 32 bits and pointers are 4 bytes.
How do you manage ownership of memory in a large C codebase?
Clear, documented ownership conventions for who allocates and frees, since the language enforces nothing.
Ambiguous ownership leading to leaks and double-frees.
What concurrency hazards exist in C?
Data races on shared memory need synchronisation (mutexes, atomics); the memory model defines what’s guaranteed.
Shares data across threads with no synchronisation.
How do you reason about performance in C?
Cache behaviour, memory layout, avoiding unnecessary allocations, and measuring with a profiler rather than guessing.
Micro-optimises without profiling.
Build and score a full interview with our free interview scorecard tool, browse the full question hub, or see how we interview engineers.