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:
168 comments Page 16 of 17.

Pavani said:   2 decades ago
Void is the data type used to declare pointer type variables but not the ordinary varibles..
eg
void *p; //correct
void p//not applicable

Dany said:   2 decades ago
We cant declare variable as a void in c..........It is valid for function.......IF WE use pointer then we can use (void*) as a datatype known as generic pointer....

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

Lohija said:   2 decades ago
One should not declare as the datatype because the void data type can be used for pointer variables.

Mass said:   2 decades ago
In printf statement we should have ambesend symbol as &v.

Karthi said:   2 decades ago
Void is a return type. It cannot be assigned for variables.

Arjun Reddy said:   2 decades ago
Void is not a datatype.

It is a keyword.

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

Gertin samules said:   2 decades ago
void datatype wont allocate any memory so if void type means nothing but void* makes sense when sending generic type of data to functions and they act like generic pointers which can be converted to other types..

Nithin said:   2 decades ago
void is a return type and variable should not declare to it.


Post your comments here:

Your comments will be displayed after verification.