Why is array not pointer?

	char a[2] = {'x', 0};
	char *p = a;

By saying p is a pointer, we mean the number saved in p’s address is an address, correct?
But the number saved in a’s address is not an address, at all. That’s my explanation why array is not pointer.

To dig deeper, consider this:
1. when you ask a’s rvalue, it returns it’s address, which is all the confusion comes from.
this is what happens when you do things like

		char *p = a;
		func(a); //func take char* as a parameter

2. when you ask a’s address, again, it returns it’s address. This is somewhat like a’s lvalue.
This why it’s so hard to clearly answer the question “does array have lvalue?”.
But still, my answer has to be that array doesn’t have lvalue.

Comments are closed.
%d bloggers like this: