Pointer Sort Issue

Hi!:) I am working on creating a binary search program. Before the search, though, I am supposed to sort the names (input by the user) alphabetically. I wrote the code for the sort and it builds cleanly. However, when I run it, it blows up right when it should sort. I don't know what I should do to fix it... Can someone please give it a look and kill my frustration?

ReadNames.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <string.h>
#include "ReadNames.h"

void Sort (char * pStr [], int NumNames)
	{
	bool Sorted;
	int i;
	cout << endl;
	do
		{
		Sorted = true;
	//	NumNames--;
		for (i = 0; (i < NumNames); i++)
			if (_strcmpi (pStr [i], pStr [i + 1]) > 0)
				{
				char * temp;
				temp = pStr [i];
				pStr [i] = pStr [i + 1];
				pStr [i + 1] = temp;
				Sorted = false;
				}
		} while (!Sorted);
	}
Try for (i = 0; (i < NumNames -1 ); i++)
That was it! Thank you so much!
Topic archived. No new replies allowed.