diff options
Diffstat (limited to 'libacc/tests/data/pointers.c')
-rw-r--r-- | libacc/tests/data/pointers.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libacc/tests/data/pointers.c b/libacc/tests/data/pointers.c new file mode 100644 index 0000000..461ebeb --- /dev/null +++ b/libacc/tests/data/pointers.c @@ -0,0 +1,15 @@ +int main() { + int* pa = (int*) malloc(100); + int* pb = pa + 1; + int* pc = (int*) 0; + *pa = 1; + *pb = 2; + printf("Pointer difference: %d %d\n", pb - pa, ((int) pb) - ((int) pa)); + int c = * (pa + 1); + printf("Pointer addition: %d\n", c); + printf("Pointer comparison to zero: %d %d %d\n", pa == 0, pb == 0, pc == 0); + printf("Pointer comparison: %d %d %d %d %d\n", pa < pb, pa == pb, pa > pb, ! pb, ! pc); + free(pa); + return 0; +} + |