| 1. |
Define Void Pointer? |
|
Answer» A void POINTER is pointer which has no specified data type. The keyword ‘void’ is preceded the pointer VARIABLE, because the data type is not SPECIFIC. It is ALSO known as a generic pointer. The void pointer can be pointed to any type. If needed, the type can be cast. Ex: float *float_pointer; int *int_pointer; void *void_pointer; . . . . . . . . . . . . . . . . void_pointer = float_pointer; . . . . . . . . . . . . . . . . void_pointer = int_pointer; A void pointer is generally used as function parameters, when the parameter or return type is UNKNOWN. A void pointer is pointer which has no specified data type. The keyword ‘void’ is preceded the pointer variable, because the data type is not specific. It is also known as a generic pointer. The void pointer can be pointed to any type. If needed, the type can be cast. Ex: float *float_pointer; int *int_pointer; void *void_pointer; . . . . . . . . . . . . . . . . void_pointer = float_pointer; . . . . . . . . . . . . . . . . void_pointer = int_pointer; A void pointer is generally used as function parameters, when the parameter or return type is unknown. |
|