我正在实现一个冒泡排序功能,它可以对单词进行排序.交换功能字很好,但我无法得到错误.尝试在线搜索,但无法获得有用的东西.我已经标记了我得到错误的地方.
感谢您的帮助.
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); } }