Exactly. There are lots of very good reasons for using pointers, but you won't see them until you start working with bigger, more complex programs. You'll start creating and destroying data on-the-fly (using malloc() for example) and you'll start working with entire data structures instead of simple variables. Once you start getting into object-oriented programming, you'll start using them even more.
I do think the example that was posted is particularly inadequate to introducing passing variables by reference when it could very easily have been dealt with as a return value.
Code:
#include <stdio.h>
int squareIt(int x) {
return x*x;
}
int main (int argc, const char * argv []) {
int square;
square = squareIt(5);
printf("5 squared is %d.\n", square);
return 0;
}
How would you extend that to create a function that would return both the square and the cube of the argument?
That's one place where passing by reference or complicated data structures can come in.
B