Driver Program??

Write your question here.
I created this code according to what the question asked me to do. But I am confused on the last part of the question. Problem: Modify the selection function presented in this chapter into an array of strings instead of an array of ints. Test the function with a driver program. The last part is where im lost. What is a driver program? Am I ok with what I have, do I need more?
#include <iostream>
#include <string>
#include<iomanip>
using namespace std;

void selectionSort (string[],int);

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

cout<<"Here are the list of the names: "<<endl;

for(int index=0;index<NUM_NAMES;index++)
cout<<setw(15)<<names[index]<<endl;

selectionSort(names,NUM_NAMES);


return 0;
}

void selectionSort (string names[], int size)
{
int startScan;
int minIndex;
string minValue;

for (startScan=0; startScan<(size-1);startScan++)
{
minValue=startScan;
minValue=names[startScan];
for (int index=startScan+1;index<size;index++)
{
if (names[index]<minValue)
{
minValue=names[index];
minIndex=index;
}
}
names[minIndex]=names[startScan];
names[startScan]=minValue;
}
}
Last edited on
Topic archived. No new replies allowed.