summaryrefslogtreecommitdiff
path: root/13_read_arr1
diff options
context:
space:
mode:
authorHaidong Ji2022-04-15 15:51:30 -0500
committerHaidong Ji2022-04-15 15:51:30 -0500
commit442a49ad5a48d417345959b903ae6a6d32d55759 (patch)
treec7127bb497e5e439018b1915e0136eec2c9cb124 /13_read_arr1
Great C programming funHEADmaster
Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git
Diffstat (limited to '13_read_arr1')
-rw-r--r--13_read_arr1/.gitignore1
-rw-r--r--13_read_arr1/Makefile2
-rw-r--r--13_read_arr1/README10
-rw-r--r--13_read_arr1/answer.txt6
-rw-r--r--13_read_arr1/grade.txt8
-rw-r--r--13_read_arr1/test.c21
6 files changed, 48 insertions, 0 deletions
diff --git a/13_read_arr1/.gitignore b/13_read_arr1/.gitignore
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/13_read_arr1/.gitignore
@@ -0,0 +1 @@
+test
diff --git a/13_read_arr1/Makefile b/13_read_arr1/Makefile
new file mode 100644
index 0000000..c6b178d
--- /dev/null
+++ b/13_read_arr1/Makefile
@@ -0,0 +1,2 @@
+test: test.c
+ gcc -o test -pedantic -std=gnu99 -Wall -Werror -lm -ggdb3 test.c
diff --git a/13_read_arr1/README b/13_read_arr1/README
new file mode 100644
index 0000000..bae9732
--- /dev/null
+++ b/13_read_arr1/README
@@ -0,0 +1,10 @@
+
+ 1. Execute the code in "test.c" by hand, and write the output
+ printed to the terminal into a file called "answer.txt"
+
+ 2. Create a Makefile to compile test.c into a program called "test"
+
+ 3. Run test and use its output to check your work.
+
+ 4. Submit your Makefile and your answer.txt file.
+
diff --git a/13_read_arr1/answer.txt b/13_read_arr1/answer.txt
new file mode 100644
index 0000000..08771c6
--- /dev/null
+++ b/13_read_arr1/answer.txt
@@ -0,0 +1,6 @@
+*p = 5
+Now *p = 16
+anArray[0] = 5
+anArray[1] = 42
+anArray[2] = 9
+anArray[3] = 12
diff --git a/13_read_arr1/grade.txt b/13_read_arr1/grade.txt
new file mode 100644
index 0000000..0b31ec9
--- /dev/null
+++ b/13_read_arr1/grade.txt
@@ -0,0 +1,8 @@
+Grading at Tue 12 Oct 2021 02:57:12 AM UTC
+Attempting to compile test.c
+gcc -o test -pedantic -std=gnu99 -Wall -Werror -lm -ggdb3 test.c
+compiled
+Your file matched the expected output
+Your output matched what we expected
+
+Overall Grade: A
diff --git a/13_read_arr1/test.c b/13_read_arr1/test.c
new file mode 100644
index 0000000..824b502
--- /dev/null
+++ b/13_read_arr1/test.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int main(void) {
+ int anArray[] = {5,16,33,99};
+ int * p = anArray;
+ printf("*p = %d\n", *p);
+ p++;
+ printf("Now *p = %d\n", *p);
+ int * q = &anArray[3];
+ int ** x = &q;
+ **x = 12;
+ *x = p;
+ **x = 42;
+ q[1] = 9;
+ for (int i =0; i < 4; i++){
+ printf("anArray[%d] = %d\n",i, anArray[i]);
+ }
+ return EXIT_SUCCESS;
+}