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:
168 comments Page 9 of 17.
Hardik said:
1 decade ago
Can not declare like this void is keyword it's not a datatype.
Shine said:
1 decade ago
What does a null ptr point to? If it is a ptr it should point to some location so is it that nothing is stored at that location?
Maragatha veni said:
1 decade ago
In printf statement how it is possible to print the value of 'v', hence we does not have to return anything using void data type, how it is possible to display the output.
This program will get syntax error.
This program will get syntax error.
Saki said:
1 decade ago
Here declaration of a variable must be done by using predefined and user defined datatypes as void is also a predefined data type also we cannot use it here which it does not allocates any memory during declaration of variable.
ex: int a=0;
int i=0; these statements can be correct.
ex: int a=0;
int i=0; these statements can be correct.
Shantanu said:
1 decade ago
While initializing the variable requires a valid data type. void is return type not a data type.
Vijay kumar said:
1 decade ago
Void mean empty or NULL value. So void keyword cannot use variable declaration in C.
Lokesh sharma said:
1 decade ago
It is void keyword which do not return any value.
Yusuf MJ said:
1 decade ago
No data type is there to 'v' here.
Void is not a data type to be assigned to any variable.
Void is not a data type to be assigned to any variable.
Shiva Keerthi said:
1 decade ago
Void is not a "data type". Its a result type or a "side effect" of a function. Result type again need not be always binary, like true or false, it can be interpreted as having some result or having no result. About void pointers. They cannot be deference since void pointers indicate the absence of type and also pointer arithmetic is not possible since "data" can not be determined. !
Srinivas said:
1 decade ago
void is an predefined data type, void means nothing.
So we can't define variables for void.
So we can't define variables for void.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers