Im working on this program for class. I have an idea on were the problem lies, but i dont know how to begin fixing it. i beleave the problem is in the void functions at the bottom. it needs to be changed around, but i dont know were or what to change. does anyone have any suggestons? Here is the code i have so far. the program origionaly sorted numbers into numeric order. no i want it set up to put words in alphabetical order. this program is set up to take four names (all the stooges) and put them in alphabetical order.
#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
void sort(string n); // change int to string
void swap(string*p1, string*p2); // change int to string
string a[4]; // change int to string
int main ()
{
int i; // i is a counting varable
for (i = 0; i < 4; i++)
{
cout << "Enter stooge names" << i << ":";
getline(cin, a[i]); //change cin >> a[i]; to getline(cin, a[i]);
}
sort(4);
cout <<"\nHere are all the stooge names, sorted:\n" << endl;
for (i = 0; i < 4; i++)
cout << sort[i] << "";
cout <<"\n\n";
system("Pause");
return 0;
}
void sort(string n)
{
int i, j, low;
for (i = 0; i < n - 1; i++)
{
low = i;
for (j = i + 1; j < n; j++)
if (a[j] < a[low])
low = j;