what is void data type
Void is an empty data type normally used as a return type in C/C++, C#, Java functions/methods to declare that no value will be return by the function.
The another use of void is to declare the pointer in C/C++ whe It is not sure that what data type will be addressed by the pointer.
eg:
void *p;
Here p can hold the address of int or float or char or long int or double.
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.
as function data type: no value returned (eg: void exit ())
as function parameter: no parameters (eg: getpid (void))
as pointer: generic pointer (void *genptr)
void is not a data type, void means empty. We use void when declaring a function:
void getd();
now getd() function will not return any value.
The voiddata type is used when a function doesn't return any value, and/or when it has no parameters at all. Pointer type 'void *' is a generic pointer.A void pointer is used when it needs to be assigned to different data types later on in a program. Since it avoids type checking, void pointers should be used with care.
Void - is empty data type in C
void is type of pointer that usually means that you can make it point to any data type. When you make a pointer point to somewhere its data type should match with the place where you want it to point. When you dont know the data type where it will point to then you can declare a void pointer and make it point to the data type it want.
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
void as function return-type means no return value void as function parameter means no parameter void * as pointer type means generic pointer
doesn't return the value.
void isn't an actual data-type, preemptive(?) or otherwise.
The voiddata type is used when a function doesn't return any value, and/or when it has no parameters at all. Pointer type 'void *' is a generic pointer.A void pointer is used when it needs to be assigned to different data types later on in a program. Since it avoids type checking, void pointers should be used with care.
Void - is empty data type in C
void is type of pointer that usually means that you can make it point to any data type. When you make a pointer point to somewhere its data type should match with the place where you want it to point. When you dont know the data type where it will point to then you can declare a void pointer and make it point to the data type it want.
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
Void Pointer is a General purpose pointer ,that does not have any data type associated with it and can store address of any type of variable. Declaration: void * pointer_name;
void as function return-type means no return value void as function parameter means no parameter void * as pointer type means generic pointer
Pick any three: int, char, long, void, char *, void *
The void type has only one purpose: to specify the return type of a function that has no return value. In this case void simply means no type. The only other usage is when used as a pointer to void (void*), which simply means a pointer type that can refer to any type of object. If the pointer is non-null, it must be cast to a specific type before it can be dereferenced.
A return type describes the type of data which is returned by a call to a method. They keyword void is used to describe a method which does not return any data.
Basically data types are divided into three types namely, 1. primary data type -> this is sub divide into int, float, char, void. 2. derived data type -> this is sub divide into array, pointer. 3. user defined data type -> this is sub divide into struct, union, enum, typedef. by, k.p.sruthi