Created
October 11, 2020 23:14
-
-
Save 911992/faba76690222e635858ab9dde193e6ef to your computer and use it in GitHub Desktop.
Need more brain for add
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
//https://github.com/911992 | |
//clone: https://ideone.com/nW8NGx | |
#define B 1024 | |
#define A 1024 | |
int main(void) { | |
int a=A; | |
int b=B; | |
int c; | |
//meh | |
c = a + b; | |
printf("meh add: %d\n",c); | |
//not cool | |
c = a - -b; | |
printf("not cool add: %d\n",c); | |
//good | |
c = A; | |
for(int k=0;k<b;k++){ | |
c+=1;//not c++ because I hate it | |
} | |
printf("good add: %d\n",c); | |
//better | |
c=A; | |
while(b--){ | |
c++; | |
} | |
printf("better add: %d\n",c); | |
//cool | |
b=B; | |
c = &((b[((void*)a)])); | |
printf("cool add: %d\n",c); | |
//cool^^^ explination: | |
/* | |
(void*)a means pointing on memory at point a(1024), no accessing, just pointing | |
b[(void*)a] is just like (void*)a[b], that means go for relative position of b(1024) of address point a(1024) | |
it's just like array indexig, a[1024], which in C, this is possible to have 1024[c] for more brainie stuff | |
finally the &(b[(void*)a]) means getting the address(not access) of the target mem add, here as 1024 forward of 1024 | |
cool nah? | |
*/ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment