OgreSwamp
OgreSwamp

Reputation: 4692

Passing by reference in Xcode, C language

I'm implementing stack in C and I define pop function in C file:

int pop(int &x, int &y);

Xcode shows error (pointing on the first argument): Expected ')' Any ideas why I have that problem? Thanks.

Upvotes: 0

Views: 1043

Answers (2)

detly
detly

Reputation: 30332

C doesn't have "pass by reference" like C++. To implement something like this, you need to use pointers:

int pop(int *x, int *y);

...and somewhere else, in a function...

int a, b;
int c = pop(&a, &b);

(It's hard to know exactly what syntax details to give without knowing more about what the arguments are meant to be.)

Upvotes: 4

Schnouki
Schnouki

Reputation: 7717

C does not have references. C++ has.

Upvotes: 2

Related Questions