pointers
pointers
pointers is one of the data type that use to store memory location of the already declared data type, to store integers we have int data type, to store floating point values we have float data type, to store characters we have char datatypes, as like to store memory of something we have pointers data types.
rule for the pointers are it can hold memory of same data type, means if we want to store int data types memory then we have to use int pointer and for char we have to use char pointer you got the point...
Declaration of pointers:
data type * variable_name ;
Example:
int * ptr ;
Initialization of pointers:
pointer = &variable name // now pointer holds memory location of variable
ptr = &a;
Accessing the value at memory by using * operator
*ptr gives value stored in that location
declaration and Initialization of pointer:
// declare ptr and store memory of variable togatore
data_type * ptr = & variable_name;
example:
int *ptr = &number;
Let's look at this...