summaryrefslogtreecommitdiff
path: root/11_read_ptr1/test.c
diff options
context:
space:
mode:
Diffstat (limited to '11_read_ptr1/test.c')
-rw-r--r--11_read_ptr1/test.c26
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;
+}