Void is an empty data type that has no value. We use void data type in functions when we don’t want to return any value to the calling function.
Example:
void sum (int a, int b); – This function won’t return any value to the calling function. int sum (int a, int b); – This function will return value to the calling function.
We use void data type in pointer like “void *p”. It means, pointer “p” is neither pointing to int data type nor char data type. It acts as generic pointer. We are using void pointer when we are not sure on the data type that this pointer will point to. We can use void pointer to refer either integer data or char data. But, this void pointer should not be dereferenced without explicit type casting.
We use void in functions as “int function_name (void)”. Here void means, this function does not pass any argument.
Void is an empty data type that has no value. We use void data type in functions when we don’t want to return any value to the calling function.
Example:
void sum (int a, int b); – This function won’t return any value to the calling function.
int sum (int a, int b); – This function will return value to the calling function.
We use void data type in pointer like “void *p”. It means, pointer “p” is neither pointing to int data type nor char data type. It acts as generic pointer. We are using void pointer when we are not sure on the data type that this pointer will point to. We can use void pointer to refer either integer data or char data. But, this void pointer should not be dereferenced without explicit type casting.
We use void in functions as “int function_name (void)”. Here void means, this function does not pass any argument.
need an explanation for this answer? contact us directly to get an explanation for this answer