for loop not looping?

this is my for loop, it doesn't loop through? It is a function that is calling other functions, why do the functions prevent the for loop from looping through all 25 (0-24) numbers?
When i loop through the file it goes to a different number of iterations each time? sometimes it only loops through once? sometimes 4-5 but never the proper amount?



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void selectionSort (int size [], int array)
{
  int min_pos;
  int max;
  for (int i=0; i < 24; i++)
        {
  cout << size [i] << "  you ";
  max = findMax (size, array, i);
        if (max !=i)
        swap (&i, &max);
        }
  cout << endl << endl << size [2] << endl << endl;


}
Last edited on
Hi @avalesky,
1.- maybe is looping

2.-maybe your swap
function is changing your
counter variable i and
altering your loop
thank you! I think you are right!
You are welcome!
Topic archived. No new replies allowed.