chars
入力からの配列と、最初の配列の対応するポインタを含むもう1つの配列があり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;