Pointer dereference in C++
Level 378 keystrokes
ptr holds the address of x. *ptr reads x through the pointer (10), and assigning to *ptr changes x itself, so x then prints 20.
C++ code
1int x = 10;// Stores the address of x in ptr2int* ptr = &x;// Dereferencing with * reads the value at that address: 103cout << *ptr << endl;// Assigning through *ptr writes into x4*ptr = 20;// x itself has changed: prints 205cout << x << endl;Output
10 20
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 8;× 5*× 3=× 3&× 1