Questions
C questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Compiler Warnings in C and C++: Enable and Treat Them as Errors
Learn why compiler warnings matter in C and C++, how to enable useful warning flags, and when treating warnings as errors is appropriate.
Convert a String to an Integer in C: atoi vs strtol
Learn safe string-to-integer conversion in C. Compare atoi and strtol, validate input, detect errors, and prevent overflow.
Convert an int to a String in C with snprintf
Learn how to convert an int to a string in C with snprintf, handle buffer sizes safely, and format struct data for reliable file output.
Convert char to int in C and C++
Learn how to convert a char to an int in C and C++, including character codes, digit conversion, examples, mistakes, and practical usage.
Correct Format Specifier for double in printf in C
Learn whether to use %f or %lf for double in printf in C, why it works, and how printf differs from scanf with float and double.
Creating an Array of Strings in C
Learn how to create arrays of strings in C using string pointers or fixed-size character arrays, with safe initialization and printf usage.
Debug vs Release in CMake: Build Types, Compiler Flags, and C vs C++ Compilation
Learn how CMake handles Debug and Release builds, compiler flags, and mixed C/C++ targets with clear examples for GCC projects.
Default Function Arguments in C: Alternatives and Patterns
Learn why C has no default function arguments and use wrappers, configuration structs, and explicit values to design clear C APIs.
Definition vs Declaration in C and C++: What’s the Difference?
Learn the difference between declarations and definitions in C and C++ with simple examples, common mistakes, and practical usage.
Dereferencing a Pointer in C and C++ Explained with Examples
Learn what dereferencing a pointer means in C and C++ with simple examples, syntax, common mistakes, and practical usage.
Detect Operating Systems in the C Preprocessor
Learn reliable C preprocessor checks for Windows, Linux, macOS, and iOS using compiler-defined macros and Apple TargetConditionals.
Detecting Unused #include Directives in C and C++
Learn how to find and safely remove unused C/C++ #include directives, reduce build dependencies, and keep headers self-contained.
Difference Between #include <...> and #include "..." in C and C++
Learn the difference between #include with angle brackets and quotes in C and C++, including search paths, examples, and common mistakes.
Difference Between ++i and i++ in C
Learn the difference between pre-increment and post-increment in C, how they behave, and which one to use in a for loop.
Difference Between `char s[]` and `char *s` in C
Learn the difference between `char s[]` and `char *s` in C, including memory layout, storage duration, mutability, and runtime behavior.
Difference Between malloc and calloc in C
Learn the difference between malloc and calloc in C, including memory initialization, syntax, use cases, and common mistakes.
Difference Between struct and union in C
Learn the difference between struct and union in C, how memory is shared, when to use each, and common mistakes with clear examples.
Dividing an Integer by 2 in C: / vs Right Shift
Learn when to use / 2 and >> 1 in C, including integer truncation, signed values, unsigned values, portability, and compiler optimization.
Escaping the Percent Sign in C printf
Learn how to print a literal percent sign with C printf, why %% works, and how format strings differ from C escape sequences.
Fast Integer Range Checks in C and C++: Unsigned Subtraction
Learn inclusive integer range checks in C and C++, when unsigned subtraction can use one comparison, and how to avoid overflow and benchmark mistakes.