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:
2 decades ago
Void can be used as int, char so what is the error in the above program.
Arjun Reddy said:
2 decades ago
Void is not a datatype.
It is a keyword.
It is a keyword.
Karthi said:
2 decades ago
Void is a return type. It cannot be assigned for variables.
Mass said:
2 decades ago
In printf statement we should have ambesend symbol as &v.
Lohija said:
2 decades ago
One should not declare as the datatype because the void data type can be used for pointer variables.
Vj Thakur said:
2 decades ago
We cannot create simple variable as a void because void means nothing.
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....
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
eg
void *p; //correct
void p//not applicable
Deboshree said:
2 decades 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