Pointer In C
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 /p>
i.e. at run time. The pointer variable might be belonging to /p>
any of the data type such as int, float, char, double, short etc /p>
Normal variable stores the value whereas pointer variable stores the address of the variable. /p>
The content of the C pointer always be a whole number i.e. address. /p>
Always C pointer is initialized to null, i.e. int *p = null./p>
The value of null pointer is 0.
Example:
#include < stdio.h >
int main()
{
int *ptr, q;
q = 50;
/* address of q is assigned to ptr */
ptr = &q;
/* display q's value using ptr variable */
printf("%d", *ptr);
return 0;
}
<< PREVIEW >>
<< NEXT >>
Comments
Post a Comment