i dont know how to pass an array to a function so it can be sorted and passed back to be displayed!!!!!
i know how to do the sort just not how to pass the array
i dont know how to pass an array to a function so it can be sorted and passed back to be displayed!!!!!
i know how to do the sort just not how to pass the array
prototype/function would look something like this:
void function(int array2[], int size);
the call would look something like this:
#define ROWS 50
int array[ROWS];
function(array, ROWS);
Basicaly whatever gets done with array2 gets done with array. Your really passing the address of the original array. Theres really no way to pass the "contents" of the whole array at one, unless you only want to pass one element.
You dont necessarility need to pass the size, but I like to make as generic functions as I can that will work with any array rather than having to hard code the size of the array in the function. Unless your dealing with char arrays in which case you'll most likely be dealing with one that ends in '\0'.
Last edited by dharh; 04-02-2002 at 01:04 PM.
to pass the array.
put
void array_name(int []) if it is an integer array
then when you are calling your function
put
function_name(array_name)
you do not need to return the array from the function because any change you make to the array will be changed in main().
greast thanx