C语言-结构(一)

来源:互联网 发布:linux 解压war包 编辑:程序博客网 时间:2024/05/13 08:58

一、结构声明,结构变量 

例如:

struct book {

    char title[MAXTITL];

    char author[MAXAUTL];

    float value;

} library ; //在定义之后跟变量名

或者

struct book {

    char title[MAXTITL];

    char author[MAXAUTL];

    float value;

} ;

struct book library;


二、定义结构变量

初始化:

struct book library = {

    "The Pirate and the Devious Damsel",

    "Renee Vivotte",

    1.95

};

访问结构成员(相当于“超级数组“”)

例如:

    gets(library.title);

    scanf("%f",&library.value);


0 0
原创粉丝点击