What is the fundamental difference between a struct and a union in terms of memory layout?
Explain 'Structure Padding' and 'Alignment.' Why does the sizeof a struct often exceed the sum of its members?
What is the difference between 'Deep Copy' and 'Shallow Copy' when dealing with structs containing pointers?
Explain the difference between Structure Packing and Structure Padding. When is packing required?
How do bit-fields work in a struct, and what are the potential portability issues associated with them?
What is an opaque pointer (or incomplete type), and how does it help in implementing encapsulation in C?
What is the difference between typeof and typeof_unqual in C23?
Explain the use case for _BitInt(N). When would you use it over a standard int or long?
What is the difference between const char *p, char * const p, and const char * const p?
What is the difference between an array and a pointer in C?
What is the difference between void * and a null pointer?
What is pointer arithmetic, and why is ptr + 1 different for a char* vs an int*?
What is a void pointer, and why can't you perform pointer arithmetic on it directly?
What is the purpose of a void* pointer, and what are the risks of using it?
Explain the concept of 'Pointer Decay' when passing an array to a function.
What is an enumeration (enum) and how does it differ from a series of #define constants?
Why is C often referred to as a 'Mid-level' language rather than a High-level language?
Is the break statement mandatory in a switch case? What happens if you omit it, and when might you do so intentionally?
Explain 'Short-circuit Evaluation' in C logical expressions.
What is the difference between pre-increment (++i) and post-increment (i++)?
Where are string literals stored in memory, and why is modifying them undefined behavior?
What is recursion, and what are the tradeoffs of recursive versus iterative solutions in C?
What is the const keyword used for, and what does const correctness mean in C?
Why doesn't C support function overloading, and how do developers typically work around this limitation?
What is the difference between signed and unsigned integers, and what happens on overflow for each?
What is two's complement, and how does C represent negative integers?
Why might n++ execute faster than n = n + 1 on certain architectures?
Declarations Storage & Linkage
When would you use the extern keyword, and what happens at the linking stage if it's missing?
What is the difference between a declaration and a definition?
Explain the difference between 'Actual Parameters' and 'Formal Parameters'.
Explain the three different meanings of the static keyword in C depending on its context.
What does the register keyword suggest to the compiler, and is it still relevant in modern C development?
What is the difference between a static local variable and a static global variable?
What is the difference between a translation unit and a source file?
What is the difference between extern and static for global variables?
How does the auto keyword in C23 differ from its historical meaning in older C standards?
What is the difference between 'Internal Linkage' and 'External Linkage'?
What is the difference between virtual and physical memory, and how does the TLB speed up memory access?
Memory Management & Layout
Explain the difference between the stack and the heap. When would you choose one over the other?
Explain the difference between malloc() and calloc() in terms of initialization and performance.
What happens to a local variable's memory after a function returns?
What is 'Stack Overflow,' and what are the most common conceptual causes in a C program?
What is a memory leak, and how do you detect or prevent it in a C program?
What is the difference between a microcontroller and a microprocessor in the context of C programming?
What is the memory layout of a C program? Explain the text, data, BSS, heap, and stack segments.
How does realloc work, and what are the pitfalls of using it incorrectly?
What is size_t, and why should it be used for sizes and array indices?
How does malloc() know how much memory to free when you only pass it a pointer?
How does a memory allocator like malloc actually work under the hood, and what are the tradeoffs of different allocation strategies?
What are the tradeoffs of using alloca() vs. malloc()?
What is a flexible array member, and when would you use one?
Compilation & Preprocessor
What are 'include guards' and what specific problem do they solve in large-scale header inclusion?
What is the difference between a typedef and a #define for creating aliases?
What are the tradeoffs of using a #define macro versus a const variable?
Why are #define macros considered unsafe compared to inline functions?
What is the difference between #include <file.h> and #include "file.h"?
Can you walk through the four stages of the C compilation process (Preprocessing, Compilation, Assembly, Linking)?
Explain the difference between a macro and an inline function. When would you prefer one over the other?
Explain the purpose of the constexpr keyword in C23. How does it differ from a #define macro?
What do the stringizing (#) and token-pasting (##) operators do in macros?
What is _Static_assert, and how does it differ from a runtime assert?
What is a function pointer, and what is a real-world use case for them such as callbacks or jump tables?
What is 'Undefined Behavior' in C, and why is it more dangerous than a compiler error?
How does printf handle a variable number of arguments? Explain the concept of va_list.
Does the sizeof() operator evaluate the expression passed to it at runtime? Why or why not?
What is a reentrant function, and why is it critical in multi-threaded or interrupt-driven environments?
How would you implement polymorphism or virtual functions in pure C?
What does the _Generic keyword (C11) do, and how does it enable pseudo-polymorphism in C?
What is the purpose of setjmp and longjmp? When are they preferred over standard control flow?
Embedded & Systems Programming
Explain bitwise operations. Why are they critical for systems programming?
Explain the volatile keyword. In what specific scenarios would a compiler's optimization break code if this keyword is missing?
What is the difference between static linking and dynamic linking, and what are the tradeoffs regarding binary size and updateability?
Explain the difference between 'Pass by Value' and 'Pass by Reference' using pointers and the architectural tradeoffs of each.
What is endianness, and why does it matter when writing C code that communicates over a network or reads binary files?
What is an Interrupt Service Routine (ISR), and why can't you pass parameters to it or return values from it?
What is a Watchdog Timer, and how does software interact with it in C?
Explain the difference between 'Polling' and 'Interrupt-driven' I/O.
What are the limitations of an Interrupt Service Routine (ISR)?
What is the restrict keyword, and how does it help the compiler optimize code?
What is Memory-Mapped I/O (MMIO), and how do you access a hardware register in C?
Why is it considered bad practice to use printf() or malloc() inside an Interrupt Service Routine (ISR)?
What is 'Interrupt Latency,' and what factors contribute to it?
Memory Safety Vulnerabilities
Why is it generally considered dangerous to return the address of a local variable from a function?
What is a dangling pointer, and what happens if you dereference it?
What is a NULL pointer, and how does it differ from an uninitialized pointer?
What is a dangling pointer, and how does it differ from a wild pointer?
What is a 'Buffer Overflow' at a conceptual level, and how does C's design contribute to this vulnerability?
What is the difference between nullptr (C23) and the traditional NULL macro?
What is a double free and a use-after-free, and why are they dangerous?
Expressions Evaluation & Undefined Behavior
Explain the concept of 'L-value' and 'R-value' in the context of C expressions.
What is Undefined Behavior (UB)? Give three examples of common C operations that result in UB.
Is the order of evaluation of function arguments defined in C? Why does this matter?
What is the 'Strict Aliasing Rule' and how does it affect how pointers of different types interact?
Explain the concept of a 'Sequence Point' and how it relates to expressions like i = i++.
How does C handle integer promotion and type conversion in mixed-type expressions?
What is undefined behavior in C, and why is i = i++ + ++i considered UB?
Concurrency & String Memory Functions
What is the difference between strcpy and strncpy, and why is the latter often considered safer but still potentially dangerous?
What is a race condition, and how do you use a mutex to prevent one in a multi-threaded C application?
What is the difference between memcpy and memmove, and when must you use memmove?
Explain the difference between a mutex and a semaphore, and when is a spinlock more efficient than a mutex?