Based on the following snippet in C
int c1,c2; printf("%d ",&c1-&c2); Output : -1
printf("%d ",&c2 - &c1)
printf("%d ",(int)&c1 - (int)&c2)
1) int. - - ( ptrdiff_t). , , .
int
ptrdiff_t
2) , undefined. .
3) . "" . / ( ). . (hex/dec/oct/...).
undefined.
C99 6.5.6 Additive, ( ):
6.5.6
, , ; . , type ( ) ptrdiff_t, . , undefined.
, undefined, .
printf ptrdiff_t %td, undefined, .
printf
%td
1) printf, , , . undefined, .
2) , -4, . , . , c2 (&c1 + 1).
c2
(&c1 + 1)
3) (int)&c1 c1 int. , , undefined, , int , . (int 32 64- ). intptr_t int.
(int)&c1
c1
intptr_t
1) * - , . (). int.
2) , ;). :
int a[2]; a[0] = 3; *(a + 1) = 5; // same that "a[1] = 5;"
"5" . :
*(a + 1 *sizeof(*a)) = 5;
3) - . int! :
int a = 0xFF; printf("%d\n", a); // print 255
, .
Source: https://habr.com/ru/post/1545374/More articles:Matplotlib color panel for PatchCollection overrides colors - pythonHow to compress video file on iphone - iosThe variable is null in a super call - javaAn exception to the BufferedReader.reset () method - javaКак вызвать/вызывать fsc, компилятор F #, из FAKE? - f#How can we store any text language (English, Hindi, Spanish etc) and extract the same value from the database - javaOpen random port - dockerIs there any quick algorithm to calculate log2 for numbers that have cardinality 2? - cAngularJS + Atmosphere Websockets: is it possible to retrieve attributes in AtmosphereResource from an HttpServlet? - javaDependency Injection with Parallel Processing - c #All Articles