Skip to content

Instantly share code, notes, and snippets.

@22shubh22
Created August 16, 2018 17:23
Show Gist options
  • Save 22shubh22/04a873988f2a317224c534828d22011f to your computer and use it in GitHub Desktop.
Save 22shubh22/04a873988f2a317224c534828d22011f to your computer and use it in GitHub Desktop.
//Please do not run the program, but draw the memory picture to determine the output.
void Unknown(int *p, int num);
void HardToFollow(int *p, int q, int *num);
void Unknown(int *p, int num) {
int *q;
q = #
*p = *q + 2;
num = 7;
}
void HardToFollow(int *p, int q, int *num) {
*p = q + *num;
*num = q;
num = p;
p = &q;
Unknown(num, *p);
}
main() {
int *q;
int trouble[3];
trouble[0] = 1;
q = &trouble[1];
*q = 2;
trouble[2] = 3;
HardToFollow(q, trouble[0], &trouble[2]);
Unknown(&trouble[0], *q);
cout << *q << " " << trouble[0] << " " << trouble[2];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment