#define BufferSize 1024 // 合适的大小你知道的
typedef struct node {
char *buffer
struct node *next
}*linkList
LinkList *InitList() {
LinkList *head
head = (char *)malloc(size(node))
head->next = NULL:
return head
}
void AddData(LinkList *head, char *data) { // 将新数据添加到表尾
LinkList *p = head
LinkList *anode = (char *)malloc(size(node))
anode->buffer = (char *)malloc(size(BufferSize))
strncpy(anode->buffer,data,BufferSize)
anode->next = NULL:
while(p->next) p = p->next
p->next = anode
}
void DealData(LinkList *head) {
LinkList *p = head->next
if(p) {
head->next = p->next
// p->buffer指向的数据待处理
free(p->buffer)// 处理完毕,释放空间
free(p)
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function test(){
alert("就这样添加!")
}
</script>
</head>
<body>
<input id="button1" type="button" value="button" onclick="test()"/>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)