Wrote your sheet on c. But at the end of the program crashes with the error: Run-Time Check Failure # 2 Stack around the variable "l" was corrupted.
main.c:
#include "objects.h" int main() { list l; init_list(&l); return 0; } object.c:
#include <stdio.h> #include <stdlib.h> typedef struct _comp { struct _comp *next; struct _comp *prev; } comp; typedef struct _list { comp *first; comp *tail; } *list; void init_list(list l) { comp *first = (comp*)malloc(sizeof(comp)); if (first == NULL) { fprintf(stderr, "failed to allocate memory.\n"); exit(-1); } comp *last = (comp*)malloc(sizeof(comp)); if (last == NULL) { fprintf(stderr, "failed to allocate memory.\n"); exit(-1); } first->prev = NULL; last->next = NULL; first->next = last; last->prev = first; l->first = first; l->tail = last; } objects.h
typedef struct _list *list; void init_list(list l);
void init_list(list l);andlist l; init_list(&l);list l; init_list(&l);? Is that how you work? - Harry