sorting a string array

Hello everyone. Here is my problem. I have a char array which I need to separate into words by "," symbol by using strtok function. Then I need to sort those "words" in an alphabetic order depending from the first symbol. I've written that part to break the array to words but I can't figure out how to sort them. Please can you help me with ?

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char inputString[100];
char* wordArray;
char** mainArray = new char* [100];
for(int i =0;i<100;++i)
{
mainArray[i] = new char[50];
}
int k;
cin.getline ( inputString, 100, '.' );
wordArray = strtok ( inputString, "," );
int j = 0;
while (wordArray)
{
cout << wordArray << endl;
strcpy(mainArray[j++], wordArray);
wordArray = strtok (NULL, ",");
}
cin >> k;
return 0;
}
Topic archived. No new replies allowed.