Color theme
0 day streak0 XPP1
CLearn mode
MISSION 1 OF 1

Edit a route through a pointer

0 XP earned
C track: AdvancedMission: AdvancedPointersPointer arithmeticDereferencing
Before you start this advanced track

Arrays and functions, plus the basics of memory addresses, pointers, and byte sizes.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A pointer stores the address of an object. Adding one to an array’s starting address reaches its second element, because pointer arithmetic moves in units of the element type. The unary * accesses the pointed-to integer. Assigning through that dereference edits the original array while the pointer continues to address the same element.

mission.c
#include <stdio.h>int main(void) {  int route[] = {4, 7, 9};  int *stop = route + 1;  *stop = 8;  printf("%d %d %d\n", route[0], route[1], route[2]);  return 0;}

Each example is a complete C11 console program. Compile as C, not C++. Arrays are local objects with the sizes shown; no input or external files are needed.

Track the values line by line. Predict the result before running this example in your own editor.