Passing reference in C-Function

Started by
2 comments, last by Woltan 13 years, 6 months ago
Hey folks,
I ran across a problem in C. As a native C++er, I am used to declaring a function like this:
void Func(int&);


However, as I am now being forced to program in C the compiler cannot compile this because of the interger reference I am trying to use as a parameter. Is this a featur which is only implemented in C++?

I hope you can help me out here!
Thx in advance
cherio Woltan
Advertisement
Yes, references are C++. Pass by pointer in C instead.
void Func(int *);
References are in C++ only. In C, use a pointer. You should either assert() that the pointer is not null (only checked in Debug mode!), or include a full runtime check and gracefully handle the case where the pointer is null.
Great,
thank you for your quick help! Too bad this feature is not implemented in C. I really got used to it!
Thx again
cherio Woltan

This topic is closed to new replies.

Advertisement