You can define pointers to every data-type (including elementary types, structures, unions, arrays and function), plus you can define generic pointers as 'void *'.
typedef void (*myfunptr)(void);extern void fun1 (void), fun2 (void), fun3 (void);myfunptr ptrs[] = {fun1, fun3, fun3};ptrs[0]();ptrs[1]();...
Data-type void has some special features:- it doesn't have values- it doesn't have size- you cannot declare variables with it- void *pointers cannot be dereferenced
A void array is an array of unknown type. That is, it is an array of pointers to unknown data types (void*). A void array op is an operation that returns a void array. Void arrays are commonly found in C code but are rarely encountered in C++.
Pointer variables and function pointers are the two primary types, as well as a void pointer (unknown type). Pointer variables can point to any valid type, including primitive types and user-defined types, as well as other pointer variables. Function pointers can point to any function with the same signature as the function pointer itself. Void pointers can point anywhere.
A pointer which keeps address of a function is known as function pointer. example: { void *(*ptr)(); ptr= &display; (*ptr)(); return(0); } void display() { .................. )
Example: int **myfun (void) { int **myptr= calloc (sizeof (int *), 100); return myptr; }
A void pointer is a pointer that has no type information attached to it.A null pointer is a pointer that points to "nothing". A null pointer can be of any type (void included, of course).
It is not possible to declare a two-dimensional array using an array of pointers in any programming language, but many programming languages support declarations of N-dimensional arrays of pointers.The exact syntax varies with the programming language, and requires support for N-dimensional arrays and pointers. In C, the following declares an array of pointer variables, each implemented as pointer to the generic type "void":void* array_1D[10];The type of the expression array_1D is "void * const."The following example expands on the previous one by declaring a two-dimensional array of "void" pointers:void* array_2D[10][20];The type of the expression array_2D is "void ** const."The last example declares a 3-dimensional array of "void" pointers, which can be seen as a 2-dimensional array of arrays of pointers:void* array_3D[10][20][30];
A Null pointer has the value 0. void pointer is a generic pointer introduced by ANSI. Before ANSI, char pointers are used as generic pointer. Generic pointer can hold the address of any data type. Pointers point to a memory address, and data can be stored at that address.
Generic pointers are pointers of the type void*. They can point to any object, but you cannot dereference a void* nor can you perform pointer arithmetic because the compiler won't know the runtime type of the object you are actually pointing at. It's up to you to determine the proper runtime type and then cast the pointer to the appropriate pointer type.
Void is not relay a data type as there is no size of storage associated with it where as char, int, long, float etc have a specific size (how many bytes are required to store the variable in). When it comes to pointers void is the universal pointer. When void is used as a function argument in a function prototype. void foo(void) The first void means that the function does not return a value. The second void means that there are no function arguments for the function. This should not be confused with. void* bar(void *) Bar returns a pointer of type void and receives an argument of a void pointer.