ref_par
Let's examine parameter passing by reference in greater detail...
The Program
/*********************************************
** File: ref_par.c
** Author: R. Chang
** Date: ?
** Section: Any
** EMail: chang@cs.umbc.edu
** Modified by: Sue Evans
** Modifucation date: 9/25/05
**
** This program demonstrates parameter
** passing by reference.
**********************************************/
#include
/* function prototype */
void F (int a, int * b);
int main()
{
int m, n ;
m = 3 ;
n = 5 ;
F(m, &n) ;
printf("%d, %d\n", m, n) ;
return 0;
}
/**********************************************
** Function F
** Inputs: an arbitrary integer, a
** a pointer to an integer, b
** Output: ???????
** there is no return value
**
** F is a function written to illustrate
** call by reference
**********************************************/
void F (int a, int * b)
{
a = 7 ;
*b = a ;
b = &a ;
*b = 4 ;
printf("%d, %d\n", a, *b) ;
}
The Sample Run
4, 4
3, 7
Last Modified -