Learn C Programming

Lesson 3 of 10 · Pointers and Memory

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

  1. Amara's sum, walked with a pointer
  2. An array's name is the address of its first box
  3. a[i] and *(a + i) are the same box
  4. In a parameter list, int a[] is int *a
  5. Where an array and a pointer differ
  6. The index of a found box, by subtraction
  7. strchr and strstr, read properly at last