diff options
author | Tomek CEDRO <cederom@tlen.pl> | 2011-11-03 02:18:57 +0000 |
---|---|---|
committer | Tomek CEDRO <cederom@tlen.pl> | 2011-11-03 02:18:57 +0000 |
commit | ad9f081b6152a9c36bfb4bf74299f6ad959088c9 (patch) | |
tree | 65dd7c577fb1d890017fe6198106ae51a32bf149 | |
parent | 0add1edbe7c67eb882417692b15c5794d2792430 (diff) | |
download | openocd+libswd-ad9f081b6152a9c36bfb4bf74299f6ad959088c9.tar.gz openocd+libswd-ad9f081b6152a9c36bfb4bf74299f6ad959088c9.tar.bz2 openocd+libswd-ad9f081b6152a9c36bfb4bf74299f6ad959088c9.tar.xz openocd+libswd-ad9f081b6152a9c36bfb4bf74299f6ad959088c9.zip |
Added simple pointer test program to testing/pointertest.c.
-rw-r--r-- | testing/pointertest.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testing/pointertest.c b/testing/pointertest.c new file mode 100644 index 00000000..0b5432e8 --- /dev/null +++ b/testing/pointertest.c @@ -0,0 +1,24 @@ +#include <stdlib.h> +#include <stdio.h> + +int f2(int *pf21, int *pf22){ + int *stuff; + stuff=(int*)calloc(1,sizeof(int)); + if (!stuff) exit(-1); + *stuff=0xDEADBEEF; + printf("stuff[@%X]=%X\n", stuff, *stuff); + *pf21=stuff; + *pf22=*stuff; + return 0; +} + +int f1(int *pf11, int *pf12){ + return f2(pf11, pf12); +} + +int main(){ + int a1=0,a2=0; + f1(&a1,&a2); + printf("a1[@%X]=%X\na2[@%X]=%X\n", &a1, a1, &a2, a2); + return 0; +} |