Pointer
In C we also give pointer a type which, in this case, refers to the type of data stored at the address we will be storing in our pointer.
/*
In C when we define a pointer variable we do so by preceding its name with an asterisk.
In C we also give pointer a type which, in this case, refers to the type of data stored at the address we will be storing in our pointer.
*/
#include<stdio.h>
void main()
{
int a=20;
int *ptr;
ptr=&a; // pointer ptr stores the address of variable a
printf("value at a: %d \n",a);
printf("address of a: %u \n",&a); //%u is used for address
printf("value at pointer ptr: %u \n",ptr);
printf("value at the address stored in the pointer: %d\n",*ptr);
printf("address of pointer: %u\n",&ptr);
}
Download Program


