-
code problem
I am trying to do insertion sort with list (ADT), I wrote the function InsertionSortList in the sort.c file:
Code:
void
InsertionSortList(List L)
{
Position P1, P2;
ElementType temp;
for(P1 = L; P1->Next != NULL; P1 = P1->Next) //problem
{
temp = P1->Element; //problem
for(P2 = P1; (P2->Last != NULL) && (P2->Last->Element < P2->Element); P2 = P2->Last) //problem
P2->Element = P2->Last->Element; //problem
}
}
while i am compling my programme, the gcc complier said:
dereferencing pointer to incomplete type
these problems happend at the lines which I indicate in the function
How can I deal with it? Thx a lot!
-
The sort.c file, may be useful.:)
-
can you post the headers "fatal.h" and "list.h". I have a feeling that you have just declared the structures but haven't actually defined them.
ie. You told the compiler a structure name but haven't given any body to that name.
-
-
-
yup, this code
Code:
/* Place in the interface file */
struct Node
{
ElementType Element;
Position Next;
Position Last;
};
is in list.c
put it into list.h
-
could you tell me where shold I put it in list.h?
thx:)
-
in list.h
the line
replace it with the structure body.
-