C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Point Out Errors (Q.No. 2)
2.
Point out the error in the following program.
#include<stdio.h>
int main()
{
    void v = 0;

    printf("%d", v);

    return 0;
}
Error: Declaration syntax error 'v' (or) Size of v is unknown or zero.
Program terminates abnormally.
No error.
None of these.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
165 comments Page 12 of 17.

Ambi said:   1 decade ago
You can never create a void variable. Only Creation of void pointer is possible.

Divya said:   1 decade ago
Void returns only zero.
We cannot use it like data type only use return type.

Karthick,sairaj said:   1 decade ago
We can't use void for variable declarations. Since void returns NULL values.

Rakesh kumar said:   1 decade ago
In c void means the variable we contains null value, which is not possible.

Vikas said:   1 decade ago
We can't create a void variable but we can create a void pointer variable.

Bhagyesh said:   1 decade ago
Void is not using for declaration of variable in c and in oop's language.

Prathik said:   1 decade ago
Void can be used as int, char so what is the error in the above program.

Ashitosh m n said:   10 years ago
We not declare or initialize a variable using void.

It is not possible.

Sandeep said:   2 decades ago
I run it on Dev C IDE then the error variable or field v declared void!

Vj Thakur said:   1 decade ago
We cannot create simple variable as a void because void means nothing.


Post your comments here:

Your comments will be displayed after verification.