[Dev-C++] System crash happen when I run a very simple linear list' program.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <per...@ya...> - 2004-06-02 00:51:25
|
I have writed a simple program just only construct two empty linear list.The process of compile is no problem.But after run it,the system crash occur.If I remove the sentence (2),the problem will not come.Can
anyone tell me how to do If I want to use the function InitList() separate to construct two empty list?
Thanks,
Bruce.J
My program list below:
/* A simple program that want to construct two empty linear list */
#define LIST_INIT_SIZE 10
typedef int ARRAY;
typedef struct {
ARRAY *elem; /* a pointer of one dimension array */
int length; /*the linear list current length */
int listsize; /* the linear list's space that has distributed */
}LineList;
/* construct a empty linear list */
ARRAY *InitList(LineList *list)
{
list->elem = (ARRAY *) malloc(LIST_INIT_SIZE * sizeof(ARRAY));
list->length = 0;
list->listsize = LIST_INIT_SIZE;
return list->elem;
}
main()
{
LineList *list, *list1;
/* want to create two empty linear list */
list->elem = InitList(list); /* sentence (1) */
list1->elem = InitList(list1); /* sentence (2) */
system("PAUSE");
}
---------------------------------
Do You Yahoo!?
嫌邮箱太小?雅虎电邮自助扩容! |