C Programming - Const - Discussion
Discussion Forum : Const - Point Out Errors (Q.No. 8)
8.
Point out the error in the program.
#include<stdio.h>
const char *fun();
int main()
{
*fun() = 'A';
return 0;
}
const char *fun()
{
return "Hello";
}
Discussion:
3 comments Page 1 of 1.
Sam said:
7 years ago
Can you explain what is Rvalue and Lvalue?
(1)
Xyz said:
9 years ago
Yes, you are right, Thank you @Pedro.
Pedro said:
1 decade ago
Even if you remove the const-ness that has an error because *fun() is an Rvalue and you cannot assign 'A' to it.
So basically you are asking which check is done first by the compiler, which is implementation dependent I guess.
So basically you are asking which check is done first by the compiler, which is implementation dependent I guess.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers