C/C++ Arena

Step 1 of 10

Addresses and pointers

Every variable lives at an address in memory. &x gives you that address. A pointer is a variable that stores an address.

int hp = 100;
int *p = &hp;     // p points at hp
printf("%d\n", *p);   // 100: *p means "the value p points at"
*p = 75;              // changes hp itself!
printf("%d\n", hp);   // 75

Your turn: make p point at armor, then use p (not armor directly) to set it to 50.

Next: Change the caller's variable