typedef struct {
double x;
double y;
} Point;
typedef struct {
Point *p1, *p2, *p3;
double area;
} Triangle;
struct node {
void* info;
struct node* next;
};
typedef struct node List;
What i need to understand is how to build the List* pointlist since every point is not just a single value but has x and y, so here's what i tried to do:void buildListOfPoints(List **headRef, void* data)
{
List* newNode = malloc(sizeof(List));
newNode->info = data;
newNode->next = *headRef;
*headRef = newNode;
}
int main()
{
Point p; // struct Point variable
List *head = NULL;
buildListOfPoints(&head, ??? ); // I want to add the point to the list but how do i do that?
while(head != NULL) {
printf("%.2lf", head->info);
head = head->next;
}
printf("\n");
return 0;
}
My problem is with the call to the buildListOfPoints() function, i don't understand how to pass a point value which should be a p.x and p.y for example.. any help? Thanks


Sign In
Create Account

Back to top









