声明

  1. typedef struct node_s{
  2. int field1;
  3. char field2;
  4. unsigned char buf[32];
  5. }node_t,*Node;//normally use.
  6. struct{ //the unnamed struct.
  7. int field1;
  8. int field2;
  9. }foo,bar;//define two struct variables.
  10. //这个结构体没有名字。这里直接定义了具有这种结构的两个结构体变量。

赋值

  1. struct node_s temp;
  2. node_t* pnode=(Node)malloc(sizeof(node_t));
  3. temp=*pnode;//method 1
  4. memcpy(&temp,pnode,sizeof(node_t));//method 2
  5. //目前不知这两种方法区别