Skip to content

Commit

Permalink
Released assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrodCoding committed Jun 19, 2020
1 parent fc3ac2e commit bdd5443
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions 12_read_ptr2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
10 changes: 10 additions & 0 deletions 12_read_ptr2/README
Original file line number Diff line number Diff line change
@@ -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


30 changes: 30 additions & 0 deletions 12_read_ptr2/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>

int f(int ** r, int ** s) {
int temp = ** r;
int temp2 = **s;
int * z = *r;
*r = *s;
*s = z;
printf("**r = %d\n",**r);
printf("**s = %d\n",**s);
*z += 3;
**s -= 8;
**r -= 19;
return temp + temp2;
}

int main(void) {
int a = 80;
int b = 12;
int * p = &a;
int * q = &b;
int x = f(&p, &q);
printf("x = %d\n", x);
printf("*p = %d\n", *p);
printf("*q = %d\n", *q);
printf("a = %d\n", a);
printf("b = %d\n", b);
return EXIT_SUCCESS;
}

0 comments on commit bdd5443

Please sign in to comment.