使用C语言编写一个关于结构的示例程序

使用C语言编写一个关于结构的示例程序

The structure is a collection of different datatype variables, grouped together under a single name Syntax.

Declaration and initialization of structures

The general form of structure declaration is as follows −

datatype member1; struct tagname{ datatype member2; datatype member n; };登录后复制

tagname - 指定结构的名称

member1, member2 - 指定构成结构的数据项。

示例

struct book{ int pages; char author [30]; float price; };登录后复制