Click to See Complete Forum and Search --> : C- pass by reference?


dr1500
11-05-2002, 06:17 PM
Hey
I learned C++ in school and now I'm doing C.
Can you pass by reference in C?
Right now I'm trying but my compiler (gcc) won't let me.
EX:
void check_mail(int &old_size){}

When I try to compile, it says there's a parse error before '&'. :(
What's up?
Thanks.

Luke

bastard23
11-05-2002, 06:30 PM
dr1500,
No, pass by reference is a feature of C++. C++ has better type checking. What you will have to do is use pointers. i.e:

void check_mail(int *old_size){}

and then call it with:
int size;
check_mail(&size); // pass a pointer.
check_mail(size); // Error

Good Luck,
chris

dr1500
11-05-2002, 06:55 PM
Whoa, I just accidentally posted a new thread.
But anyway, I used pointers and they worked.
Thanks.

Luke

X_console
11-05-2002, 10:50 PM
Just so you know, you can delete your own threads by clicking Edit on the post and then checking the Delete box that comes up.

dr1500
11-06-2002, 01:07 AM
Cool. :D