Pointer Basics in C
Level 385 keystrokes
Demonstrates pointer declaration, the address-of operator (&) and the dereference operator (*). The printed address differs between runs and machines.
C code
// An ordinary int stored somewhere in memory1int x = 10;// int * means "pointer to int"; &x gives the address of x2int *ptr = &x;// *ptr reads the value stored at that address: 103printf("Value: %d\n", *ptr);// %p prints the address itself in hex; it changes on every run4printf("Address: %p\n", ptr);Output
Value: 10 Address: 0x7ffd5e8c3a4c
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.
;× 4"× 4,× 2:× 2(× 2)× 2*× 2\× 2%× 2=× 2