Các C pro giúp mình đoạn code này với:
#include <stdlib.h>
#include <string.h>
typedef struct ListElmt_ // Define a structure for linked list elements.
{
void *data;
struct ListElmt_ *next;
} ListElmt;
typedef struct List_ //define a structure for linked lists.
{
int size; // the size of the linked list
ListElmt *head; // the head element
ListElmt *tail; // the tail elemtent
} List;
void list_init(List *l)
{
l->size = 0;
l->head = NULL;
l->tail = NULL;
}
int main()
{
List *ls = NULL;
list_init(ls);
return 0;
}
Mình đã compile với -Werror, không có lỗi gì nhưng chạy là bị segmentation fault các pro ạ.
Mình lần rồi nhưng chưa tìm thấy chỗ nào, đành phải dùng trợ giúp từ cộng đồng.
Sáng mai, đoạn code đơn giản và đầy tự tin
Và rồi… ăn ngay gáo nước lạnh 

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?