Loading…
Loading…
Language
Articles and problems tagged C.
A C string is a char array ending in '\0'. Learn why the terminator matters, how to walk a string with indexes and pointers, and how to print and read strings safely with %s, scanf and fgets.
Exercises on 3-D array addresses, arrays of pointers to rows and blocks, a spot-the-bug puzzle on undefined behaviour, and shuffled pointer arrays. Full answers with diagrams.
Short questions that test whether you truly understand arrays and pointers: array vs pointer access, when an array name is not its base address, arr vs &arr, char a[] vs char *a, and more.
Advanced puzzles combining pointers to pointers, arrays of pointers and multi-dimensional arrays. Untangle expressions like **++ptr and *++*ptr with diagrams and step-by-step answers.
More worked puzzles: pointers that walk through arrays forwards and backwards, ++ and * combinations, and pointer subtraction. Each answer is explained step by step with runnable code.
Worked puzzles on arrays and pointers: array names as base addresses, pointer arithmetic, sizeof, and 2-D array addresses. Predict each output, then read the step-by-step explanation.
Build arrays that hold addresses, and allocate memory while the program runs with malloc, calloc, realloc and free. Learn to size requests with sizeof, check for NULL and avoid memory leaks.
A C function cannot return an array directly. Learn the ways around it: returning pointers, static arrays and their shared-storage trap, typedefs for array pointers, and caller-provided buffers.
How a three-dimensional array is stored in memory, how to reach any element using pointer notation, and how to pass 3-D arrays to functions, with clear memory diagrams.
What really happens when you pass an array to a function, and how two-dimensional arrays are stored row by row. Learn pointers to arrays and the ways to receive a 2-D array in a function.
How arrays are laid out in memory, why an array name gives its base address, and how pointer arithmetic moves by whole elements. Learn why a[i] means *(a + i) and which pointer operations are allowed.
Practice exercises on pointer basics: predict outputs, find bugs and write small programs using addresses, pointer variables and functions that receive addresses. Solutions included.
Test your understanding of &, * and pointers to pointers with worked puzzles. Predict each program's output, then check the step-by-step explanation and the corrected modern C.
Why pointers have types, how passing addresses lets a function change the caller's variables (call by reference), and how to return pointers safely without leaving them dangling.
A pointer is a variable that stores an address. Learn how to declare and use pointer variables, how a pointer to a pointer works, and the jargon of pointers, with memory diagrams.
Every variable in C lives at an address in memory. Learn what an address is, how the & operator gets it, and how the * operator reads the value stored there, with runnable examples and diagrams.