What is the difference between pointer to vector and pointer to variable?

1
int A;
int* pA = 1;
int Vect[2] = {1,2};
int* pVect;

pA = &A;
*pA = 2;

pVect = Vect;
pVect[0] = 10;

In the case I have a pointer to a variable and then to a vector, and I want to change its values by the pointer. Why is there such a divergence in address passing (in the variable I have to use & and in the vector does not need)? Is this proper to C language?

As far as I know the pointer, it points to the memory address of that variable obtained by & , but for vector it does not need & .

    
asked by anonymous 29.03.2017 / 06:31

1 answer

3

If you consider that a vector is a variable, there is no difference at this point.

A pointer points to a memory address, period. The address can be obtained in several ways. One is a pointing to a vector. You can access a vector by a pointer in a natural way. The variable that accesses a vector is a pointer. Being a pointer you do not have to use & .

See more:

29.03.2017 / 09:24