fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int val1 = 1000;
  5. int val2 = 2000;
  6. int val3[2] = {3000, 4000};
  7.  
  8.  
  9. int *b[3];
  10.  
  11.  
  12. *(b+0)= &val1;
  13. *(b+1) = &val2;
  14. *(b+2) = val3;
  15.  
  16. //Prints 1000
  17. //Prints what the first element of b is pointing at
  18. printf("%d\n",b[0][0]);
  19. printf("%d\n",**(b+0) );
  20.  
  21. //Prints 2000
  22. printf("%d\n", b[1][0] );
  23. printf("%d\n",**(b+1) );
  24.  
  25. //Prints 3000
  26. printf("%d\n", b[2][0] );
  27. printf("%d\n", **(b+2) );
  28.  
  29. //Should print 4000 i think, but prints 2000, why?
  30. printf("%d\n", b[2][1] );
  31. printf("%d\n", *(*(b+2)+1) );
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
1000
1000
2000
2000
3000
3000
4000
4000