C and C++ topics
- Hello World in C: Write, compile and run your first C program, and learn what each line of Hello World does.
- C variables and data types: int, double, char and friends. How to declare variables in C, what each type holds, and how big they are.
- printf format specifiers: A cheat sheet for printf in C, from %d, %f, %s and %c to width, precision and %zu for sizes.
- Reading input with scanf: How to read numbers and words from the keyboard in C with scanf, and how to check that it worked.
- if, else and switch in C: Making decisions in C with if, else if, else and switch, plus the comparison and logical operators.
- Loops in C: for, while and do-while: How for, while and do-while loops work in C, with break, continue and the common off-by-one mistakes.
- Functions in C: Defining and calling functions in C, parameters, return values, prototypes and pass by value.
- Recursion explained: What recursion is, why every recursive function needs a base case, and how the call stack makes it work.
- Arrays in C: Declaring, indexing and looping over arrays in C, 2D arrays, and why arrays passed to functions lose their size.
- Strings in C: How C strings work as char arrays ending in a null terminator, plus strlen, strcpy, strcmp and safe copying.
- Pointers in C explained: What a pointer is, how & and * work, and why C uses pointers to change variables, share arrays and build data structures.
- Pointer arithmetic: How adding to a pointer moves by whole elements, how p[i] relates to *(p + i), and where pointer arithmetic becomes undefined.
- malloc and free: dynamic memory in C: How to allocate memory on the heap in C with malloc, calloc and realloc, check for failure, and free it correctly.
- Memory leaks, dangling pointers and double frees: The classic C memory bugs, what causes them, and how to find them with AddressSanitizer and Valgrind.
- Structs in C: Grouping data with struct in C, the dot and arrow operators, typedef, and passing structs to functions.
- Linked lists in C: Build a singly linked list in C with malloc, push to the front, walk it, reverse it, and free it.
- Bitwise operators in C and C++: &, |, ^, ~, << and >> explained with examples: setting, clearing and testing bits, and bit flags.
- The C preprocessor and macros: #include, #define, include guards and conditional compilation, plus why macros need parentheses.
- File I/O in C: Open, read, write and close files in C with fopen, fprintf, fgets and fclose, and handle errors.
- Function pointers and callbacks in C: Store a function in a variable, pass it as a callback, and use it with qsort, with readable typedefs.
- Undefined behavior in C and C++: What undefined behavior is, the common causes (overflow, out of bounds, use after free), and how sanitizers catch it.
- Header files and multiple source files: How to split a C or C++ program into .h and .c files, what goes where, and how the linker joins them.
- C vs C++: what's the difference?: How C++ builds on C with classes, references, RAII, templates and the standard library, and when each language is used.
- References in C++: What a C++ reference is, pass by reference vs pass by value, const references, and references vs pointers.
- Classes and objects in C++: Member variables and functions, public and private, constructors, initializer lists and const member functions.
- RAII and destructors in C++: Resource Acquisition Is Initialization explained, how destructors free resources automatically, and the rule of zero.
- Operator overloading in C++: Make your types work with +, ==, <<, [] and more, with the conventions that keep overloaded operators unsurprising.
- std::vector in C++: How to use std::vector, the dynamic array of C++, plus size vs capacity, reserve, and iterator invalidation.
- std::map and std::unordered_map: Key-value lookups in C++, the difference between map and unordered_map, and the operator[] insertion trap.
- Lambdas in C++: Writing lambda functions in C++, capture by value and by reference, and using lambdas with STL algorithms.
- STL algorithms in C++: sort, find, count_if, accumulate, transform and friends, and why algorithms beat hand-written loops.
- Smart pointers: unique_ptr, shared_ptr and weak_ptr: How C++ smart pointers own heap objects and free them automatically, and when to use each one.
- Move semantics and std::move: What moving means in C++, rvalue references, what std::move really does, and the rule of five.
- Templates in C++: Function and class templates in C++, type deduction, and constraining templates with C++20 concepts.
- Inheritance and virtual functions in C++: Base and derived classes, virtual functions and override, abstract classes, and why virtual destructors matter.
- Modern C++: C++17 and C++20 features: The modern C++ features worth knowing, from auto and structured bindings to std::optional, concepts and ranges.
- Error handling in C and C++: Return codes, errno, exceptions, std::optional and std::expected, and how to choose between them.
- Big-O notation explained: What O(1), O(log n), O(n), O(n log n) and O(n^2) mean, with examples of each, for coding interviews and real code.
- Binary search: How binary search finds a value in sorted data in O(log n), how to write it without bugs, and std::lower_bound.
- Sorting algorithms compared: Insertion sort, merge sort, quicksort and counting sort compared by speed, memory and stability.
- How hash tables work: Hash functions, buckets, collisions, chaining and load factor, the ideas behind std::unordered_map.
- Binary trees and binary search trees: Tree terminology, recursive traversals, and how binary search trees keep data sorted for O(log n) lookups.
- Graphs: BFS and DFS: Representing graphs with adjacency lists, and exploring them with breadth-first and depth-first search.