I just need to clarify the variables
Does a normal variable have 2 "parts"? one part is the actual value, and the other part is the location of this value in memory
Is it correct?
So, the pointer variable is only part of the location of the normal variable, and doesnβt it matter?
If you are talking about C, then pointers simply represent a different level of indirection.
a , &a ( a) - , a . a, .
a
&a
p, , . - , .
p
, , :
int a = 7; // set a to 7. int *p = &a; // set p to the address of a.
a - 0x1234 p 0x1236 (16- int/pointer). :
+--------+ 0x1236 (p) | 0x1234 | +--------+ 0x1234 (a) | 0x0007 | +--------+
a , :
int b = a;
a 0x1234 b. :
b
int c = *p;
p 0x1236 ( 0x1234), ( '*'), a.
"2 " - . - . , , 0x0004, 7 ( v).
- , . , , 0xff0c 0x0004 ( p).
C:
v 7
& v ( v) 0x0004
p - 0x0004
& p ( p) 0xff0c
* p (, p) 7
, . , , , , .
, , int, . , .
, int. ( ) , . .
a = 100;
a (aka & a) - , , 0x1000000, 100.
, !
...
C, , -. . .
, , , . , .
int:
int x ; x = 400 ;
x , ..
printf( "x value=%d, x memory location=%d\n", x, &x ) ;
, , , . , , , 0x1234. , , @ .
, , , I.e. a = 12;. a oridnary, 12. , a - @0x1234, 12 . & , , , & - C ++, address-of ( ); &a a.
a = 12;
&
: . - , I.e. a 12, ptr , , . , value-at * , , " , , ". *ptr @, ptr. , ptr = 12;, , 12 ptr, *ptr = 1;, 1 12 .
12
ptr
*
*ptr
ptr = 12;
*ptr = 1;
1
2 ""? - , -
: . , , ( ). , . , , , .
, - - , ?
, " ". . - . . , .
, , , , , . "".
0x16 . 0x42 , 0x16. " " . , . (, 0x20 , 0x42.
, - . "" . . , . , .
, . . , .
, , 32- , , 4 . , , , , 1 , , , , 4 . , 1 !.
. .
Source: https://habr.com/ru/post/1734763/More articles:Problem copying shortcut title from dephi app? - delphiScanf_s throws exception - windowsIs it possible: rendering server tags at runtime in asp.net? - asp.netC # 2 Array Split Amount Question - c #Primitive DirectX 10 is not displayed - primitiveCSS: setting the background gradient to a width of 100%, if only scrolling pages - htmlKnow the real boundaries of the image in UIImageView - iphoneMy background does not appear - cssWhat mouse event? - javascriptTomcat6 on Linux uses 100% processor when ServerSocket is idle - javaAll Articles