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 17 of 17.
Ambi said:
1 decade ago
You can never create a void variable. Only Creation of void pointer is possible.
Mohsin said:
2 decades ago
v and *vptr is declared as void pointers and we cannot use v and *vptr until and unless we convert that variables to the desired data type.
Here we are assigning value 0 to v and v doent hold any memory location to assign the value first we have to convert void v to integer type then only we can assing the value to it.
Ex (int) v = 0 ;
or v = (int) 0 ;
Anything I am not sure.
Here we are assigning value 0 to v and v doent hold any memory location to assign the value first we have to convert void v to integer type then only we can assing the value to it.
Ex (int) v = 0 ;
or v = (int) 0 ;
Anything I am not sure.
Sandeep said:
2 decades ago
I run it on Dev C IDE then the error variable or field v declared void!
Mymuna said:
2 decades ago
Correct.
Prachi Deshmukh said:
2 decades ago
Is the question correct?
BOth the pointers point to v ?
cptr = &v;
vptr = &v;
Or is it
cptr = &c?
BOth the pointers point to v ?
cptr = &v;
vptr = &v;
Or is it
cptr = &c?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers