So far, we have used pointers that point to regular, statically
allocated variables. We used an address-of operator
& to assign the address of an existing object to our pointer. Example:
int main(void)
{
int x = 123;
int *p = &x;
printf("The value of a pointed-to object is: %d\n", *p);
}
Output:The value of a pointed-to object is: 123
We also showed how a pointer could point to an array:
int main(void)
{
int arr[] = {10, 20, 30, 40, 50};
int *p = arr;
printf("The first array element is: %d\n", *p);
}
Output: ...