Pointers in C
Addresses and dereferencing: the heart of C.
int pointer_basics(void) {
int value = 42;
int *ptr = &value;
int read = *ptr;
*ptr = 100;
int **handle = &ptr;
int deep = **handle;
return value + read + deep;
}
How it works
&valuetakes the address;*ptrreads through it.- Assigning
*ptrwrites back to the original. - A pointer-to-pointer adds another level.
Keywords and builtins used here
intpointer_basicsreturnvoid
The run, in numbers
- Lines
- 11
- Characters to type
- 164
- Tokens
- 52
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 35 seconds.
Step 1 of 5 in Pointers, step 1 of 25 in Pointers & memory.