What is pointer in C by R4R Team

Pointers:

Pointers in C language is a variable that stores/points the address of another variable. A Pointer in C is used to allocate memory dynamically i.e. at run time. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc.

Example-
int a=10;
int *p=&a;

-Here 'p' is the pointer variable which point the variable 'a'.

How get variable value by pointer ?
int a=10;
int *p=&a
printf("%d",*p);
//10

Note:
-Integer pointer only points the integer variable.
-String pointer only points the string variable.
Conclusion:
-Pointer of one type is only hold the address of similar type variable.

Double pointer:

Example-
int a=10;
int *p=&a;
int **var=&p;

print("%d,%d,%d",a,*p,**var);
//10,10,10

Note:
Double pointer is only points to single pointer.
Similarly, triple pointer only points the double pointer.
We generally make a pointer upto third level.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!