Pointer's:

Whenever a variable is declared in a program it is having same memory location in the storage device. The memory location is called address of that variable.

To declare a pointer you must put a * in front of its name.
int main()
{
int *p;
}

You can put the address of an integer into a pointer to an integer by using the & operator to get the integer's address.

int main()
{

int i;
int *p;
i = 5;
p = &i;
return 0;

}

Declaring a pointer
int* example; /* Declares a pointer to an int. */

Getting the address of a variable.
int something = 3;
example = &something. /* Makes example point to the address of something. */

Dereferencing a pointer
*example = 2; /* Sets the value of the data pointed to by example. */

array[2] = 12; /* This is equivalent to *(array+2) = 12; */




---------------- Wild pointer-------------------
A pointer in c which has not been initialized is known as wild pointer.
------------------ Far Pointer ---------------------------
The pointer which can point or access whole the residence memory of RAM (Generally 1 GB = 64KB * 16 segment ) as far pointer.
Size of far pointer is 4 byte or 32 bit.
First 16 bit stores: Segment number
Next 16 bit stores: Offset address
%Fp is used for print offset and segment address of pointer in printf function in hexadecimal number format.
eg. int far * p;
------------------ Far Pointer ---------------------------
The pointer which can point or access whole the residence memory of RAM (Generally 1 GB = 64KB * 16 segment ) as far pointer.
Size of far pointer is 4 byte or 32 bit.
First 16 bit stores: Segment number
Next 16 bit stores: Offset address
%Fp is used for print offset and segment address of pointer in printf function in hexadecimal number format.
eg. int far * p;
--------------- Null pointer ---------------------
NULL pointer is a pointer which is pointing to nothing.
---------------- Dangling pointer-----------------
If any pointer is pointing the memory address of any variable but after some variable has deleted from that memory location while pointer is still pointing such memory location. Such pointer is known as dangling pointer.
Generic pointer:
void pointer in c is known as generic pointer. Literal meaning of generic pointer is a pointer which can point any type of data.
Example:
void *p;
SHARE

About df

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment