From 442a49ad5a48d417345959b903ae6a6d32d55759 Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Fri, 15 Apr 2022 15:51:30 -0500 Subject: Great C programming fun Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git --- 11_read_ptr1/test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 11_read_ptr1/test.c (limited to '11_read_ptr1/test.c') 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 +#include + +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; +} -- cgit v1.2.3