Program crashing for no apparent reason

Guys I believe everything is right here but for some reason my program stops working everytime i try to run it Any suggestions THANKS!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <string>

using namespace std;

//function prototype
 void SelectionSort(string [] , int);

//findMin() returns index of minimum value in ary between indexes fst and lst 
int findMin(const int ary[], int fst, int lst);

 
 const int SIZE = 20;
 
 int main()
 {
	 string names[SIZE] = { "Collins, Bill", "Smith, Bart", "Allen, Jim",
        "Griffin, Jim", "Stamey, Marty", "Rose, Geri", "Taylor, Terri", 
        "Johnson, Jill", "Allison, Jeff", "Looney, Joe", "Wolfe, Bill",
        "James, Jean", "Weaver, Jim", "Pore, Bob", "Rutherford, Greg", 
        "Javens, Renee", "Harrison, Rose", "Setzer, Cathy",
        "Pike, Gordon", "Holland, Beth" };

	 //Display unsorted list
		cout << "the unsorted list: " << endl;
		cout << " -----------------------" << endl;

		//loop to display the names

		for(int count = 0; count < SIZE; count ++)
		
			cout << names[SIZE] << endl;
		

		//Call selection sort
		SelectionSort(names, SIZE);

		// loop to display sorted list
		for(int count = 0; count < SIZE; count ++)
		
			cout << names[SIZE] << endl;
		

		return 0;
 }


	

//Function definitions
 
 int findMin(const string ary[], int fst, int lst)
{
    int mndx = fst;
    for (int k = fst+1; k < lst; ++k)
        if (ary[k] < ary[mndx])
            mndx = k;
	return mndx;
}

 
 
  void SelectionSort(string names[], int size)
 {
	
    int mndex;    
    for (int k = 0; k < size - 1; k++) {
        mndex = findMin(names, k, size);
        if (mndex != k) 
            swap(names[k], names[mndex]);
    } // endfor
}





  


  
Use count instead of SIZE inside the for loop

cout << names[count] << endl; in both the places...
Thanks that did the trick
Topic archived. No new replies allowed.