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 2 of 17.
Prathik said:
1 decade ago
Void can be used as int, char so what is the error in the above program.
Arjun Reddy said:
1 decade ago
Void is not a datatype.
It is a keyword.
It is a keyword.
Karthi said:
1 decade ago
Void is a return type. It cannot be assigned for variables.
Mass said:
1 decade ago
In printf statement we should have ambesend symbol as &v.
Lohija said:
1 decade ago
One should not declare as the datatype because the void data type can be used for pointer variables.
Vj Thakur said:
1 decade ago
We cannot create simple variable as a void because void means nothing.
Dany said:
1 decade 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....
Pavani said:
1 decade 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
eg
void *p; //correct
void p//not applicable
Deboshree said:
1 decade ago
A variable cannot be of void type only a function or a pointer can be declared as void.
Venugopal said:
1 decade ago
The void type has no values therefore we cannot declare it as variable as we did in case of integer and float.
The void data type is usually used with function to specify its type. Like in our first C program we declared "main()" as void type because it does not return any value.
The void data type is usually used with function to specify its type. Like in our first C program we declared "main()" as void type because it does not return any value.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers