Solution:
- Pointers are powerful features in C programming.
- Addressing is important before start of Pointers in C.
Address in C
- If you have a variable called ‘x’ in yprogram then &x will give you its address in the memory.
- We have used address numerous times while using the scanf() function.
- scanf(“%d”, &x);
- Here, the value entered by the user is stored in the address of ‘x’ variable.
- For example.
#include <stdio.h>
int main()
{
int var = 5;
printf("x value is : %d\n", x);
printf("address of x: %p", &x);
return 0;
}
Pointers in C:
- Pointers (pointer variables) are special variables that are used to store addresses rather than values.
Pointer Declaration:
int* p or int *p;
- Here, we have declared a pointer p of int type.
- We can use asterisk(*) either preceded by variable or followed by data type.
- int* p1, p2;
- Here, we have declared a pointer p1 and a normal variable p2.