## It is rightly said that if someone masters pointers he has mastered half the C. Pointers have always been a very difficult and confusing part in C. But the power they have in the coding arena is unparalleled. They form the basis of core programming .

Lets start with this topic of pointers. First and foremost its important to read and understand the declaration of pointers. So here we go,

- int a // a is a variable to an integer.
- int *p // p is a pointer to an integer.
- int **p // p is a pointer to a pointer to an integer.
- int ***p // p is a pointer to a pointer to a pointer to an integer.
- int a[5] // a is one dimensional array of 5 integers.
- int *p[5] // p is one dimensional array of 5 integer pointers.
- int (*p)[5] // p is a pointer to one dimensional array of 5 integers. OR p is a pointer to 1 dimensional array holding base address of 2 dimensional array.
- int (*p)[5][5] // p is a pointer to two dimensional array of 5X5 integers. OR p is a pointer to two dimensional array holding base address of three dimensional array.
- int f() // f is a function which doesn’t take any parameter and returns an integer.
- int f(int) // f is a function which takes a integer parameter and returns a integer.
- int *f(int) // f is a function that takes an integer as a parameter and returns an integer pointer.
- int (*f)() // f is a function pointer (OR a pointer to a function) that takes no argument and returns an integer.
- void (*f)() // f is a function pointer (OR a pointer to a function) that takes no argument and returns nothing.
- int (*f)(int) // f is a function pointer (OR a pointer to a function) that takes integer parameter and returns an integer.
- int (*f[5]) (int) // f is one dimensional array of 5 function pointers that take integer parameter and return an integer.
- int (*f) (int*, int*) // f is function pointer (OR a pointer to a function) that takes two integer pointers (OR pointer to an integer) as arguments and returns an integer.
- char (*(*f())[3]) () // f is a function that takes no argument and returns a pointer to an array of 3 function pointers that take no argument but character.
- int (*(*f)())[5][4] // f is a function pointer that receives nothing and returns a pointer to a 2 dimensional array of 5X4 integers.
- char (*(*f[3])()) [20] // f is an array of 3 function pointers that receive nothing and return pointer to 1 dimensional array of 20 characters.
- float *(*(*(*f)())[10])() // f is function pointer that receives nothing and returns a pointer to an array of 10 function pointers that receive nothing and return float pointer.

If you master how to read and interpret a statement containing pointer it makes the way further quite pleasant. So learn this tutorial and post your comments.

Advertisements