off by one and help with swap

yesterday I posted on this same code and for the most part your help was great. but no one answered this particular problem

i have a list of accounts, i need to place them in descending order, preferable while they are being entered.

there is the code i have so far:

Code:

`-------------------------------------------------------------------------------------------------`

void sort(int accounts[],double balance[], int& total)

{

int index_of_next_smallest;

for (int index = 0; index < total - 1; index++)

{

index_of_next_smallest =

index_of_smallest(a, index, number_used);

swap_values(a[index], a[index_of_next_smallest]);

//a[0] <= a[1] <=...<= a[index] are the smallest of the original array

//elements. The rest of the elements are in the remaining positions.

}

}

*/

/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------

int index_of_smallest(int account[],int NUMBER int account[0], int& total)

{

int min = a[start_index],

index_of_min = start_index;

for (int index = start_index + 1; index < number_used; index++)

if (a[index] < min)

{

min = a[index];

index_of_min = index;

//min is the smallest of a[start_index] through a[index]

}

return index_of_min;

} */

/*------------------------------------------------------------------------------

void swap_values(int& v1, int& v2)

{

int temp;

temp = v1;

v1 = v2;

v2 = temp;

}

------------------------------------------------------------------------------*/

also the off by one problem I was able to solve and we all missed it.

when i initially called up menu one - enter an account , an account was entered even before the loop started and index was not initialiazed.

thanks to everyone for there help, this is really helping me learn, especially when i see routes that others would take.

jess