2015년 3월 14일 토요일

typedef in C

typedef struct node
{
        void* dataPtr;
        struct node* link;
} NODE;

Q1: why use 'node' when 'NODE' is the name?

-> node is part of an old type name, 'struct node'. It is not a new type name.


  • this is the typedef syntax: typdef oldTypeName newTypeName
  • struct node{ ... } = OldTypeName
  • NODE = NewTypeName

  • it's possible to define NODE without node!
typedef struct
{
    void* dataPtr;
    struct* link;
} NODE;

    댓글 없음:

    댓글 쓰기