diff options
author | Haidong Ji | 2022-04-15 15:51:30 -0500 |
---|---|---|
committer | Haidong Ji | 2022-04-15 15:51:30 -0500 |
commit | 442a49ad5a48d417345959b903ae6a6d32d55759 (patch) | |
tree | c7127bb497e5e439018b1915e0136eec2c9cb124 /11_read_ptr1/test.c |
Excellent fundamentals and displine training, many tools and techniques
exercises: gdb, emacs, valgrind, git
Diffstat (limited to '11_read_ptr1/test.c')
-rw-r--r-- | 11_read_ptr1/test.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/11_read_ptr1/test.c b/11_read_ptr1/test.c new file mode 100644 index 0000000..5d91622 --- /dev/null +++ b/11_read_ptr1/test.c @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <stdlib.h> + +void g(int x, int * y) { + printf("In g, x = %d, *y = %d\n", x, *y); + x++; + *y = *y - x; + y = &x; +} + +void f(int * a, int b) { + printf("In f, *a = %d, b = %d\n", *a, b); + *a += b; + b *= 2; + g(*a, &b); + printf("Back in f, *a = %d, b = %d\n", *a, b); +} + + +int main(void) { + int x = 3; + int y = 4; + f(&x, y); + printf("In main: x = %d, y = %d\n", x, y); + return EXIT_SUCCESS; +} |