Download presentation
Presentation is loading. Please wait.
Published byJeffery Day Modified over 8 years ago
2
1. Generic Pointer 2. NULL Pointer 3. Wild Pointer 4. Dangling Pointer
3
GGeneric pointer is also known as void pointer. GGeneric pointer is a special type of pointer which points to the data of no specific data type FFor examplevoid *ptr; Here ptr is a generic pointer. WWe can assign the address of any data type to generic pointer after its declaration. WWe use generic pointer in two situations. One when we have no idea in advance about the data type of the variable. SSecondly when we have to assign the address of different variables of different data types to the single pointer.
4
IIt is a special type of pointer which points nowhere. IIt is usually used to know if the pointer points to null or free the memory during the deallocation of memory in dynamic memory location. FFor Example: int *ptr= N ULL;
5
AAn uninitialization pointer is known as wild pointer. WWild pointer holds a garbage value. IIt is not pointing any memory location yet. FFor Example: int *ptr; is a wild pointer. AAfter the initialization it will became an ordinary pointer.
6
IIt points to a destroyed variable. IIt usually happens during dynamic memory allocation, when the object is destroyed but not free the pointer, it still pointing to the destroyed variable. FFor 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.
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.