POINTER
Pointer is a special variable that holds the address of another variable.
Declaration of pointer :
syntax: datatype * pointername ;
example : int * p ;
float * ptr ;
A pointer always meant to hold the address not an ordinary variable .
'*' is called value at address operator .
Normal variable provides direction access to their own values whereas pointer provides indirect access to the value of variable whose address it stores.
BAD POINTER :
When a pointer is first declared , it does not contain a valid address . The pointer is uninitialized or bad pointer.
Each pointer must be assigned a valid address before it can support pointer operations.
Before that pointer is bad and shouldnot be used .
Null pointer :
Pointer that does not point any value.
Void pointer :
It is syntatically incorrect to assign the address of any data type variable to any other data type variable.
A void pointer is a special kind of pointer that can hold address of a variable of any data type .
Syntax : void * pointername ;
The keyword void represents that this pointer donot have any type associated with it and type assignment must be used to change void pointer to a concrete data type we refer .
No comments:
Post a Comment