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;
}
Discussion:
165 comments Page 13 of 17.
Jayaprakash said:
1 decade ago
Void means null and we usually used to declare the return type in functions. Variable declaration usually allocates memory to the variable.
Void keyword cannot assign any memory to the variable and hence it cannot be used for variable declaration.
Void keyword cannot assign any memory to the variable and hence it cannot be used for variable declaration.
Vishwa said:
1 decade ago
In GCC it shows like this.
In function \'main\':
Error: variable or field \'v\' declared void.
void v=0;
In function \'main\':
Error: variable or field \'v\' declared void.
void v=0;
Keya said:
1 decade ago
Void is prototype so we can not initialize variable.
Vinay Singh & Pannelal Goswami said:
1 decade ago
"Void" is no return type keyword for function use, not use in variable declaration.
Shalini k said:
1 decade ago
void doesn't return anything so instead of void if int is declared we get the result as 0.
Lalita kumari said:
10 years ago
If a variable is void and when it is printed with any datatype it accept the size and data type. So how it is wrong?
Ashitosh m n said:
10 years ago
We not declare or initialize a variable using void.
It is not possible.
It is not possible.
Keyur vyas said:
10 years ago
It's not possible,
Because of we never declare or initialize this kind of variable using void.
Because of we never declare or initialize this kind of variable using void.
Dharani Reddy said:
10 years ago
Void means null. It returns nothing.
Raviteja said:
10 years ago
It's can't void as main.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers