• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download

main()1 int main() {
2     int* pa = (int*) malloc(100);
3     int* pb = pa + 1;
4     int* pc = (int*) 0;
5     *pa = 1;
6     *pb = 2;
7     printf("Pointer difference: %d %d\n", pb - pa, ((int) pb) - ((int) pa));
8     int c = * (pa + 1);
9     printf("Pointer addition: %d\n", c);
10     printf("Pointer comparison to zero: %d %d %d\n", pa == 0, pb == 0, pc == 0);
11     printf("Pointer comparison: %d %d %d %d %d\n", pa < pb, pa == pb, pa > pb, ! pb, ! pc);
12     free(pa);
13     return 0;
14 }
15 
16