Question 4.10

I have a function

	extern int f(int *);
which accepts a pointer to an int. How can I pass a constant by reference? A call like
	f(&5);
doesn't seem to work.


You can't do this directly. You will have to declare a temporary variable, and then pass its address to the function:

	int five = 5;
	f(&five);
See also questions 2.10, 4.8, and 20.1.


Read sequentially: prev next up top


This page by Steve Summit // Copyright 1995 // mail feedback