I have one array containing chars from the input and the other array containing pointers to the corresponding chars in the first array. This part went good.
But then I would like to bubble sort the char** array (array of pointers) so the original array stays untouched but something goes wrong(the text is not sorted).
EDIT: Please discuss only the sorting algorithm
char tab[200];//array of chars
char** t = new char*[tabLength];
//SOMETHING
....
....
int n = tabLength;//length of tab(length of the word it contains)
//TILL HERE EVERYTHING IS FINE -----------------------------------
//bubble sorting below
do{
for(int i = 0; i < n -1; i++){
if(*t[i] > *t[i+1]){
char* x = t[i];
t[i] = t[i+1];
t[i+1] = x;
}
n--;
}
}while(n>1);
cout<<"sorted input";
for(int i = 0; i < tabLength; i++)
cout<<t[i];
cout<<endl;
cout<<"original"<<tab<<endl;
std::string? If you did usestd::string, then you could just copy the string and then usestd::sortto sort it.