/*编程环境WIN-TC*/
#include "stdio.h"
#include "conio.h"
#define NODE(name, key_word, help) \
Node name[1]={{NULL, NULL, NULL, key_word, help}}
typedef struct node
{
struct node *next; /*兄弟节点*/
struct node *child; /*子节点*/
struct node *parent; /*父节点*/
const char *key_word;
const char *help;
}Node;
/*各节点关联构成链表*/
int node_add(Node *mynode, Node *parent)
{
if(mynode == NULL || parent == NULL)
return 0;
mynode->parent = parent;
mynode->next = parent->child;
parent->child = mynode;
return 1;
}
main()
{
/*父子兄弟节点测试*/
NODE(node_modem, "modem", "GPRS modem");
NODE(node_modem_test, "modem test", "GPRS modem test");
NODE(node_modem_run, "modem run", "GPRS modem rum");
NODE(node_modem_go, "modem go", "GPRS modem go");
node_add(node_modem_test, node_modem);
node_add(node_modem_run, node_modem);
node_add(node_modem_go, node_modem);
printf("%s",node_modem->child->next->key_word);
getch();
}