C Programming - Pointers - Discussion
Discussion Forum : Pointers - True / False Questions (Q.No. 3)
3.
The following program reports an error on compilation.
#include<stdio.h>
int main()
{
float i=10, *j;
void *k;
k=&i;
j=k;
printf("%f\n", *j);
return 0;
}
Answer: Option
Explanation:
This program will NOT report any error. (Tested in Turbo C under DOS and GCC under Linux)
The output: 10.000000
The output: 10.000000
Discussion:
23 comments Page 2 of 3.
Pruthvi said:
1 decade ago
In turbo c it is an error. And it is not the correct way to assign a void pointer.
Abi said:
1 decade ago
Hi,
Can you explain then why do we need to typecast a void pointer?
Can you explain then why do we need to typecast a void pointer?
Shabana said:
1 decade ago
Yes its correct because void is nothing we cannot assign like that.
Ankit said:
1 decade ago
But before assigning the void pointer we must typecast it. Right ?
Sboy said:
9 years ago
Invalid conversion compile time error in codeblocks windows.
Kiran ware said:
1 decade ago
Yes, before assigning the void pointer we must typecast it.
Vivek said:
1 decade ago
This is right program. No error will be there.
Vidhiyasri said:
1 decade ago
It is very useful and I will try my best.
Suki said:
1 decade ago
Can you explain what is typecast?
Siya said:
9 years ago
What is meant by typecasting?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers