Q:

WHAT IS VOID IN C?

belongs to collection: C INTERVIEW QUESTIONS AND ANSWERS

0

WHAT IS VOID IN C?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

total answers (1)

C INTERVIEW QUESTIONS AND ANSWERS

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
WHAT IS TOKEN IN C?... >>
<< WHAT IS ENUM IN C?...