1 配置数据时,sex采用了枚举类型进行定义
typedef enum tagINFO_SEX
{
INFO_SEX_FEMALE = 1,
INFO_SEX_MALE = 2
}INFO_SEX_E;
typedef struct tagINFO_CFG
{
unsigned int uiId;
unsigned int uiAge;
INFO_SEX_E enSex;
char szName[INFO_NAME_MAXLEN+1];
}INFO_CFG_S;
2 定义链表节点时,注意重定义后的结构名不要使用在本结构体中,不然我们会遇到很大的麻烦,我们来看下面的一个例子
#include<stdio.h>
#include<stdlib.h>
typedef struct tagData
{
unsigned int uiId;
unsigned int uiAge;
}DATA_S;
typedef struct tagInfo_Cfg
{
struct INFO_CFG_S *pstNext;
DATA_S stData;
}INFO_CFG_S;
int main()
{
INFO_CFG_S *pst1 = (INFO_CFG_S *)malloc(sizeof(INFO_CFG_S));
INFO_CFG_S *pst2 = (INFO_CFG_S *)malloc(sizeof(INFO_CFG_S));
INFO_CFG_S *pst3 = (INFO_CFG_S *)malloc(sizeof(INFO_CFG_S)); //在这里为了说明,我不做pst返回值判断了
pst1->pstNext = pst2;
ps