#include #include int globalInt = 10000; // ALL values are passed by value in C. // when you see a pointer parameter, you don't know if // what the code's author intends. Could be they intend // the method to return a value in the memory pointed at // by the pointer (which is call-by-reference-like). // Could be they want to provide access to something large, // like a structure, without the cost of copying it to the stack. // Could be an array, which can't be passed by value. void sub(int x, int *intPtr, int *kindaRef) { x = 0; // this is an assignment to a local variable intPtr = &globalInt; // this is an assignment to a local variable *kindaRef = 0; // this uses a local variable to access (shared) memory } int main(int argc, char *argv[]) { int localInt = 1; int refInt = 100; int *pInt = &localInt; printf("localInt / pInt / refInt => %d / %p (%d) / %d\n", localInt, pInt, *pInt, refInt); sub(localInt, pInt, &refInt); // Note that pint didn't change! printf("localInt / pInt / refInt => %d / %p (%d) / %d\n", localInt, pInt, *pInt, refInt); return 0; }