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 15 of 17.
Najamunnisa begum said:
1 decade ago
When we declare the variable memory will not be allocated but when we initialize we need memory to store that variable value.
Since, void is not a data type it results in error.
Since, void is not a data type it results in error.
HARIKRISHNAN.P said:
1 decade ago
void is a primitive data type in C.
void, in C has no size. Thus, if you were to declare a variable of type "void", the compiler would not know how much memory to allocate for it.
void, in C has no size. Thus, if you were to declare a variable of type "void", the compiler would not know how much memory to allocate for it.
Shruthi hebbal said:
1 decade ago
I think there is no datatype as void in c language.
Surbhi said:
1 decade ago
Can we create void data types in c?
Vikas said:
1 decade ago
We can't create a void variable but we can create a void pointer variable.
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.
Deboshree said:
1 decade ago
A variable cannot be of void type only a function or a pointer can be declared as void.
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
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....
Vj Thakur said:
1 decade ago
We cannot create simple variable as a void because void means nothing.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers