Pointer Arithmetic
Adding to a pointer moves by whole elements. Arrays and pointers are closely related.
Example
#include <stdio.h>
int main(void) {
int a[] = {10, 20, 30};
int *p = a;
printf("%d %d %d\n", *p, *(p + 1), p[2]);
p += 2;
printf("%d\n", *p);
return 0;
}Result
10 20 30 30
Exercise
Next element.
*(p 1)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.