saiz66 Posted August 7, 2004 Share Posted August 7, 2004 How do I pass arrays by reference?? Thanks in advance. Link to comment Share on other sites More sharing options...
0 Genesi Posted August 7, 2004 Share Posted August 7, 2004 (edited) int sum_arr(int arr[], int) //using index notation is the same as int sum_arr(int * arr, int) //passing by address Not sure if this helps. When passing an array by an address you are really passing by a pointer. When this is the case the pointer pointers to the first index within the array. Edited August 7, 2004 by Genesi Link to comment Share on other sites More sharing options...
0 saiz66 Posted August 8, 2004 Author Share Posted August 8, 2004 (edited) thank u genesi again! int sum_arr(int * arr, int) //passing by address in my main program would I pass it like this? int arr[50]; sum_arr(arr, int) ? I have a way of forgetting things... any resource available online where they have examples to refresh my memory? Edited August 8, 2004 by saiz66 Link to comment Share on other sites More sharing options...
0 kjordan2001 Posted August 8, 2004 Share Posted August 8, 2004 thank u genesi again! int sum_arr(int * arr, int) //passing by address in my main program would I pass it like this? int arr[50]; sum_arr(arr, int) ? I have a way of forgetting things... any resource available online where they have examples to refresh my memory? Yes, although I'm sure he forgot size for the name of the second parameter, since in C you can't really tell the size of an array when it gets passed. Link to comment Share on other sites More sharing options...
0 saiz66 Posted August 8, 2004 Author Share Posted August 8, 2004 oh okay.. thanks kjordan!!!!! Link to comment Share on other sites More sharing options...
Question
saiz66
How do I pass arrays by reference?? Thanks in advance.
Link to comment
Share on other sites
4 answers to this question
Recommended Posts