単語を並べ替えるバブルソート機能を実装しています。スワップ機能語は完全に問題ありませんが、エラーを取得できません。オンラインで検索しようとしましたが、何か役に立つものを得ることができませんでした。エラーが発生する場所をマークしました。
お手伝いありがとう。
void sortWord (struct node** head) {
struct node* temp = (*head);
struct node* temp2 = (*head);
int i;
int j;
int counter = 0;
while(temp != NULL)
{
temp = temp->next; //<-- this is where i get the error.
counter++;
}
for( i = 1; i<counter; i++)
{
temp2=(*head);
for(j = 1; j<counter-1;j++)
{
if(wordCompare(temp2,nodeGetNextNode(temp2))>0)
{
swap(head,temp2,nodeGetNextNode(temp2));
continue;
}
}
temp2 = nodeGetNextNode(temp2);
}
}