Module 11 · Pointers and Memory
Pointers and Arrays: the Same Thing, Almost
Free with an accountReading
Amara takes her sum_of from Module 9 lesson 05 and rewrites it without an index. A pointer starts at the first mark and steps along until it passes the last. The program prints total: 237, exactly as before. Bob asks whether she found a second way to add marks. She has found the first way again: Module 9's brackets were doing this all along.
Checking what this lesson needs for you…
What is inside Pointers and Arrays: the Same Thing, Almost
- Amara's sum, walked with a pointer
- An array's name is the address of its first box
- a[i] and *(a + i) are the same box
- In a parameter list, int a[] is int *a
- Where an array and a pointer differ
- The index of a found box, by subtraction
- strchr and strstr, read properly at last