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
(I am have been using C for a while but I am pretty still new to few concepts in C. I am trying to answer this to the best of my knowledge, feel free to correct me If I am wrong)
When you say pass by reference you pass the address, and do to so you would use pointers pointing to the addresses. So you need to pass the pointers to your function prototype but what you are doing is passing address directly.
What your function tries is de-reference(using &) your pointer, but you never had a pointer to parameters 's' and 'i' to de-reference it.
The right way to do for the function prototype/definition is
int locate(char *name, int *s, int *i)
and when you have to call this function you use the below declaration in the main or calling function
int locate(char *name, &s, &i)