您的位置:首页 > 编程语言 > PHP开发

yii 学习笔记十五、商品信息删除

2014-04-08 20:27 351 查看
Make the tail queue sample in man page work.

 

#include <sys/queue.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, const char *argv[])
{
TAILQ_HEAD(tailhead, entry) head;
struct tailhead *headp;
headp = &head;

struct entry {
int val;
TAILQ_ENTRY(entry) entries;
} *n1, *n2, *np;

TAILQ_INIT(headp);

n1 = malloc(sizeof(struct entry));
n1->val = 10;
TAILQ_INSERT_HEAD(headp, n1, entries);

n1 = malloc(sizeof(struct entry));
n1->val = 100;
TAILQ_INSERT_TAIL(headp, n1, entries);

n2 = malloc(sizeof(struct entry));
n2->val = 200;
TAILQ_INSERT_AFTER(headp, n1, n2, entries);

for (np = headp->tqh_first; np != NULL; np = np->entries.tqe_next)
printf("value: %d\n", np->val);

while (headp->tqh_first != NULL)
TAILQ_REMOVE(headp, headp->tqh_first, entries);
return 0;
}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐