typedef struct array char* 语法

2017-11-14  本文已影响0人  define南拳

typedef   int  width;

width 等同于int 类型              提高可读性

char line[81];

char text[81];

精简为:

typedef char Line[81];

Line text , line;

Line等价于char[81]

typedefchar* pstr;

1intmystrcmp(constpstr p1,constpstr p3);

隐藏指针

typedef char*  name;

name 等同于 char*类型        提高可读性

struct listnode {

    int x;

    int y;

} ;

struct listnode                这两个关键字的组合是结构体类型 

listnode                          什么都不是

struct listnode* node     结构体指针

typedef struct listnode {

    int x;

    int y;

} ListNode ;

struct listnode                这两个关键字组合起来是结构体类型

struct listnode* node     结构体指针

listnode                         什么都不是

ListNode                        是结构体类型

ListNode* node              结构体指针

#define MAX_LENGTH 10

typedef struct listnode {

    int x;

    int y;

} ListNode , LinkList [MAX_LENGTH] ;

1.初始化结构体类型 struct listnode

2.初始化结构体类型ListNode

3.初始化结构体数组,方式:ListNode LinkList[MAX_LENGTH]

struct  tagNode {

    char* pItem;

    struct    tagNode* pNext;

};

typedef    struct    tagNode* pNode;

结构体指针,也可按照如下写法:

typedef struct tagNode{

    char* pItem;

    struct     tagNode* pNext;

}*pNode;

未完待续。。。

上一篇 下一篇

猜你喜欢

热点阅读