hi all,
plz explain me.
in following code
int main()
{
int arr[5] = {1,2,3,4,5};
printf("\n *arr = %d", *arr);
printf("\n *arr = %d", *(++arr));
return 0;
}
why
printf("\n *arr = %d", *(++arr));
this line giving error: '++ needs l-value'
hi all,
plz explain me.
in following code
int main()
{
int arr[5] = {1,2,3,4,5};
printf("\n *arr = %d", *arr);
printf("\n *arr = %d", *(++arr));
return 0;
}
why
printf("\n *arr = %d", *(++arr));
this line giving error: '++ needs l-value'
Because arr is not a pointer. It is the address of the array and you cannot change to it.
Thank you very much.
but what is meaning of that error: '++ needs l-value'
Thank you very much.
but what is meaning of that error: '++ needs l-value'
Compiler messages can be funny sometimes. You really have to look at the code closely to figure out why it is saying so. I guess here the compiler is actually not able to change the value of the variable (since it is array name) and it thinks that it is because the lvalue for ++ operator does not exist.
Thank you all.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.