Loading…
Loading…
Topic
Articles and problems tagged Arrays.
Store a list of strings as a 2-D char array or as an array of pointers. Compare memory use on 64-bit systems, swapping strings, and reading strings in with malloc, with clear diagrams.
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.