Need help with this compiler error

This is a discussion on Need help with this compiler error within the C Programming forums, part of the General Programming Boards category; Hi
I'm quite new to C Programming, I only started it this semester at University.
I tried to compile a ...

My lecturer's notes regarding C has implied that we should put an ampersand before the variable when we are passing by reference, unless I have misunderstood it. Here's the direct quote:

"Simplified Pass by Reference
• To use the simplified pass by reference system of C++ in our C programs means there is only one small change that needs to be made.

• When making a call to a function and passing the parameters by reference, no changes need to be made:

GetData(a, b);

• However, the declaration of the function should indicate that the variables are passed by reference with the inclusion of an ampersand in front of their name:

void GetData(int &x, int &y)
{

• Once inside the function, you can use a variable that has been passed by reference exactly the same as normal.
• The only difference will be that any changes made inside the function will still exist when the function returns."

The compiler also gets many parameter-related errors if I take out the &.

"• For the purposes of this unit we are going to use a simplified version of how pass by reference is implemented in the C language.
• This involves using a feature of the C++ language which is an evolution of C and is backwardly compatible.
• So we are still using C but borrowing a feature from C++."

And I think my problem is because I'm compiling as a .c and not a .cpp

#include <stdio.h>
void pass_by_value(int number) // indicate an integer is being passed
{
printf("pass_by_value...\n", number) ;
printf("\tThe incoming number is %d\n", number) ; // num is 5
printf("\tThe address of number is %p\n", &number) ; // some address on the stack
number *= number ; // square it ;
printf("\tAfter squaring, number is now %d\n\n", number) ; // report new value
}
void pass_by_reference(int *number) // indicate a pointer is being passed
{
printf("pass_by_reference...\n") ;
printf("\tThe incoming number is %d\n", *number) ; // num points to 5, so use indirection
printf("\tThe address of number is %p\n", number) ; // same address as main()
*number *= *number ; // square it - have to use indirection ;
printf("\tAfter squaring, number is now %d\n\n", *number) ;
}
int main (int argc, const char * argv[]) {
int i = 5 ;
printf("main...\n") ;
printf("\tThe number is %d\n", i) ;
printf("\tThe address of number is %p\n\n", &i) ; // report it's memory address
pass_by_value(i) ; // pass the value of variable i
printf("main after calling pass_by_value...\n") ;
printf("\tThe number is now %d\n\n", i) ; // show i has not changed value
pass_by_reference(&i) ; // pass the address of variable i
printf("main after calling pass_by_reference...\n") ;
printf("\tThe number is now %d\n", i) ; // show the new value of i
return 0;
}

Here is the output. Note that with when passing by value, a new copy of the variable is created on the stack, as can be seen by its memory address being different than the address in main(), and any changes to it in the called function are not reflected in the calling function.

However, when passing by reference in C, any changes to the value are reflected in the calling function, because a new copy of the variable is not made on the stack - the calling function passed the pointer to variable to the called function.

Code:

main...
The number is 5
The address of number is 0xbffffa0c
pass_by_value...
The incoming number is 5
The address of number is 0xbffff9f0
After squaring, number is now 25
main after calling pass_by_value...
The number is now 5
pass_by_reference...
The incoming number is 5
The address of number is 0xbffffa0c
After squaring, number is now 25
main after calling pass_by_reference...
The number is now 25