Questions
C questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Why ENOENT Means "No Such File or Directory" in C and Unix Error Codes
Learn why ENOENT means "No such file or directory," what ENT stands for, and how Unix/C error codes are named and used.
Why GCC Replaces linux with 1: Understanding Predefined Macros in C
Learn why GCC may replace `linux` with `1` in C, how predefined macros work, and how to write portable code safely.
Why Hexadecimal Numbers Use the 0x Prefix
Learn why hexadecimal numbers use the 0x prefix, what it means, and how number literals are written in programming languages.
Why Use Braces for Single-Line if Statements and Loops in C++?
Learn why C++ developers use braces for single-line if statements and loops, preventing maintenance bugs and improving clarity.
Why Use Pointers in C++? A Beginner-Friendly Guide
Learn why pointers matter in C++, when to use them, and how they work with arrays through clear examples and practical guidance.
Why `a[5]` Equals `5[a]` in C: Array Indexing and Pointer Arithmetic Explained
Learn why `a[5]` and `5[a]` mean the same thing in C by understanding array indexing, pointer arithmetic, and how subscripting works.
Why `printf` Flushes on Newlines in C: Buffering Explained
Learn why `printf` may not flush immediately in C, why newlines matter, and how to force output to appear right away.
Why `sizeof(x++)` Does Not Increment `x` in C
Learn why `sizeof(x++)` does not evaluate `x++` in C, how `sizeof` works, and when expressions inside it are executed.
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.
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.
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.
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.
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.
char * const vs const char * in C and C++
Learn the difference between char * const and const char * in C and C++, including pointer constness, examples, mistakes, and use cases.
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.
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.
mmap vs read and write for File Access in POSIX C
Learn when to use mmap versus open, read, and write in POSIX C, including performance trade-offs, safety concerns, and practical examples.
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.
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.
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.