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";
}
Error: RValue required
Error: Lvalue required
Error: fun() returns a pointer const character which cannot be modified
No error
Answer: Option
Explanation:
No answer description is available. Let's discuss.
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.

Post your comments here:

Your comments will be displayed after verification.