I\'m trying to use pass by reference in C so that the function can modify the values of the parameters passed to it. This is the function signature:
int loc
If you wish to use pass by reference method to modify a parameter used in function call, always use pointers as formal arguments of function.
Hence instead of using this
int locate(char *name, int &s, int &i)
use,
int locate(char *name, int *s, int *i)
When you will call this function, you may use
.........
int a=5;
int d=10;
char c='A';
int result;
result=locate(&c, &a, &d);
I hope all would be clear now,
For more idea about passing by value or passing by reference and which one is better, this source is good for beginners
http://www.learnc.net/call-by-reference.php
Have fun.