Questions

C questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Why `typedef struct` Is Common in C

Learn why `typedef struct` is often used in C, how it differs from plain structs, and when it improves readability in real code.

cstructtypedef

Why `volatile` Is Needed in C: Meaning, Uses, and Examples

Learn what `volatile` means in C, why it is needed, when to use it, and what it does with practical examples and common mistakes.

cdeclarationvolatile

Why `while (!feof(fp))` Is Wrong in C File Reading

Learn why `while (!feof(fp))` is incorrect in C, how EOF actually works, and the right way to read files safely with fscanf, fgets, and fread.

cfilewhile-loopeof

Why alloca() Is Discouraged in C: Stack vs Heap Memory Explained

Learn why alloca() is discouraged in C, how stack allocation differs from malloc(), and when each memory approach is appropriate.

cstackmallocallocation

Why struct sizeof Is Larger Than the Sum of Its Members in C

Learn why sizeof(struct) can be larger than the sum of member sizes in C, including padding, alignment, and memory layout examples.

ccppstructsizeof

i++ vs ++i in C: Performance Difference Explained

Learn the real performance difference between i++ and ++i in C, when they behave the same, and where postfix vs prefix matters in practice.

cperformanceooppost-increment

likely and unlikely Macros in C: How Branch Prediction Hints Work

Learn how likely and unlikely macros work in C with __builtin_expect, when they help, and when branch prediction hints are worth using.

cgcclinux-kernelbranch-prediction

printf Long Format Specifier in C

Learn which printf conversion specifier formats a long in C, with examples, differences from int, and common mistakes to avoid.

cprintflong-integer

size_t vs unsigned int in C and C++: What’s the Difference?

Learn why C and C++ use size_t for sizes and indexes, how it differs from unsigned int, and when each type is appropriate.

ccppsize-t

static const vs #define vs enum in C

Learn when to use static const, #define, and enum in C, including differences, trade-offs, examples, and common mistakes.

cconstants

typedef struct vs struct in C: What's the Difference?

Learn the difference between `struct` and `typedef struct` in C, when to use each, and how they affect syntax in real C programs.

cstructtypedef

while(1) vs while(2) in C: Are They Different in Speed?

Learn how while conditions work in C, why while(1) and while(2) are both infinite loops, and whether either is faster in practice.

cperformancewhile-loop

Page 6 of 6 - 112 questions