Pointer type

I'm new to C ++, and when I read the MIT lecture on the pointer, I found out something strange:

Pointers are just variables storing integers, but these integers are memory addresses, usually the addresses of other variables. A pointer that stores the address of some variable x is called a point to x. We can access the value of x by dereferencing the pointer.

and also I found that the pointer can be of type:

int *pointer ; 
char * pointer ; //example 

Well, he just said that it is an int that contains an address that gives it the same type as the item it points to, if it just keeps a reference to it is not the actual value?

+4
source share
2 answers

, int. ""... . int, , .

int a[4] = { 0, 1, 2, 3 };

// Dereferenced pointers to an int with additonal offset of size int n times
printf("%i\n", *a);
printf("%i\n", *(a+1));
printf("%i\n", *(a+2));
printf("%i\n", *(a+3));

// Equivalent to using the array as usual
printf("%i\n", a[0]);
printf("%i\n", a[1]);
printf("%i\n", a[2]);
printf("%i\n", a[3]);

, int. , - . , ..

+1

, . 32- 32 , int reinterpret_cast. 64-, 64 32- . reinterpret_cast 64- , ? ... , .

, , , void*. , , , , , .

0

All Articles