分享

21天学通C语言(第六版)

 我是我你是你 2018-07-14

一、源代码

/***** 21天学通C语言(第六版) *****/

/***** 第11天课程 结构、共用体和TypeDef *****/

/***** 11.3结构数组 *****/

/***** 文件--- structarr.c *****/

/***** 运行环境--- Code::Blocks 17.12 *****/

/*Demonstrates using arrays of structures.*/

#include

/*Define a structure tc hold entries.*/

struct entry{

char fname[20];

char lname[20];

char phone[10];

};

/*Declare an array of structrues.*/

struct entry list[4];

int i;

int main(void)

{

//Loop to input data for four people.

for(i = 0; i < 4;="">

{

printf('\nEnter first name:');

scanf('%s',list[i].fname);

printf('\nEnter last name:');

scanf('%s',list[i].lname);

printf('\nEnter phone in 123-4567 format:');

scanf('%s',list[i].phone);

}

//Print two blank lines.

printf('\n\n');

//Loop to display data.

for(i = 0; i < 4;="">

{

printf('Name:%s %s',list[i].fname,list[i].lname);

printf('\t\tPhone:%s\n',list[i].phone);

}

return 0;

}

二、运行结果

21天学通C语言(第六版)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多