void in c






void data type in c

    Linguistic meaning of void is nothing. Size of void data type is meaningless question.

What will be output of following c code?
#include<stdio.h>
int main(){
    int size;
    size=sizeof(void);
    printf("%d",size);
    return 0;
}

Output: Compilation error

If we will try to find the size of void data type complier will show an error message “not type allowed”. We cannot use any storage class modifier with void data type so void data type doesn’t reserve any memory space. Hence we cannot declare any variable as of void type i.e.
void num;   //compilation error

Use of void data type

1. To declare generic pointer
2. As a function return type
3. As a function parameter.     




char
int
float 
double
void 
Data type tutorial home
C tutorial home.







No comments: