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'

Recommended Answers

Because arr is not a pointer. It is the address of the array and you cannot change to it.

Jump to Post

All 5 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.