Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. Generic Pointer 2. NULL Pointer 3. Wild Pointer 4. Dangling Pointer.

Similar presentations


Presentation on theme: "1. Generic Pointer 2. NULL Pointer 3. Wild Pointer 4. Dangling Pointer."— Presentation transcript:

1

2 1. Generic Pointer 2. NULL Pointer 3. Wild Pointer 4. Dangling Pointer

3 GGeneric pointer is also known as void pointer. GGeneric pointer is a special type of pointer which points to the data of no specific data type FFor examplevoid *ptr;  Here ptr is a generic pointer. WWe can assign the address of any data type to generic pointer after its declaration. WWe use generic pointer in two situations. One when we have no idea in advance about the data type of the variable. SSecondly when we have to assign the address of different variables of different data types to the single pointer.

4 IIt is a special type of pointer which points nowhere. IIt is usually used to know if the pointer points to null or free the memory during the deallocation of memory in dynamic memory location. FFor Example: int *ptr= N ULL;

5 AAn uninitialization pointer is known as wild pointer. WWild pointer holds a garbage value. IIt is not pointing any memory location yet. FFor Example: int *ptr; is a wild pointer. AAfter the initialization it will became an ordinary pointer.

6 IIt points to a destroyed variable. IIt usually happens during dynamic memory allocation, when the object is destroyed but not free the pointer, it still pointing to the destroyed variable. FFor Example: char *dp=malloc(…………) ; /*………code of the program………………………… …………code of the program………………………….*/ free(dp);// Now dp is a dengling pointer here. dp= N ULL ; // Now dp is not a dengling pointer, it is now a null pointer.


Download ppt "1. Generic Pointer 2. NULL Pointer 3. Wild Pointer 4. Dangling Pointer."

Similar presentations


Ads by Google