我有一个包含chars输入的数组,另一个数组包含指向chars第一个数组中对应的指针。这部分进展顺利。
但后来我想对char**数组(指针数组)进行冒泡排序,以便原始数组保持不变但出现问题(文本未排序)。
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;