Basic Program for Pointers
Few important points to remember:
* is used to access the value stored in the pointer variable.
& is used to store the address of a given variable.
Here is the C language tutorial on Pointers in C → Pointers in C
Below is a simple program on pointer.
int *p; is a pointer variable declaration where
p is a pointer to an
int variable i.e. it stores the location of an integer.
%x is a format specifier to print hexadecimal value. It is usually used to print the location.
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
int var = 24; // actual variable declaration
p = &var; // storing address of int variable var in pointer p
printf("\n\nAddress of var variable is: %x \n\n", &var);
// address stored in pointer variable
printf("\n\nAddress stored in pointer variable p is: %x", p);
// access the value using the pointer variable
printf("\n\nValue of var variable or the value stored at address p is %d ", *p);
printf("\n\n\t\t\tCoding is Fun !\n\n\n");