Created
January 13, 2011 11:52
-
-
Save kybernetyk/777757 to your computer and use it in GitHub Desktop.
Everything is by value in C.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void foo (int *p) | |
{ | |
printf ("\t1. p is pointing to: %p\n", p); | |
p = 0; | |
printf ("\t2. p is pointing to: %p\n", p); | |
} | |
int main (int argc, char **argv) | |
{ | |
int my_stuff = 1234; | |
int *my_p = &my_stuff; | |
printf ("1. my_p is pointing to: %p\n", my_p); | |
foo (my_p); | |
printf ("2. my_p is pointing to: %p\n", my_p); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output on my machine is: