c 结构体链表初探

结构体链表

 

 1 #include <stdio.h>
 2 struct tnode
 3     {
 4          char *word;
 5          int count;
 6          struct tnode *left;
 7          struct tnode *right;
 8     };
 9 
10 int main(int argc, char const *argv[])
11 {
12     
13     struct tnode a, b, c, *tmp;     
14     a.word = "a";
15     b.word = "b";
16     c.word = "c";
17     a.left = &b;
18     b.left = &c;
19     c.left = NULL;
20     tmp = &a;
21     char *p = NULL;
22      do {
23          printf("%s\n", tmp->word);          
24          
25      } while(tmp = tmp->left);
26 
27      return 0;
28 }

  执行结果

  a
  b
  c

 

posted @ 2017-09-16 23:14  蜗牛码  阅读(176)  评论(0编辑  收藏  举报