단어를 정렬하는 버블 정렬 기능을 구현합니다. 스왑 함수 단어가 완벽하게 괜찮지 만 오류가 발생하지 않습니다. 온라인 검색을 시도했지만 유용하지 않을 수 있습니다. 나는 어디서 오류가 발생했는지 표시했다.불완전한 클래스 유형의 포인터가 허용되지 않습니다.
도움 주셔서 감사합니다.
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);
}
}
다음 구조체에는 void *를 사용하십시오. – Dariusz