c中的结构体嵌套问题_C中的结构

c中的结构体嵌套问题

Structures in C language are basically user-defined data types that enables the user to create a data type that can group elements of different data types into it.

C语言的结构基本上是用户定义的数据类型 ,使用户能够创建一个数据类型,数据类型可以将不同数据类型的元素分组到其中

Thus, it contains different data types to be represented by a single Structure name.

因此,它包含由单个结构名称表示的不同数据类型。



用C创建结构 (Creating Structures in C)

C language uses the struct keyword to create a structure.

C语言使用struct关键字创建结构。

Syntax:

句法:


struct Structure_Name 
{
    Datatype data_member1;
    Datatype data_member2;
    .
    .
    Datatype data_memberN;
};

As mentioned above, C language uses the struct keyword to build a structure. Inside the curly brackets, the user can define the data members necessary to serve the purpose of the particular program. These data members are the basic C language variables of different data types such as int, float, double, char, etc.

如上所述,C语言使用struct关键字来构建结构。 在大括号内,用户可以定义实现特定程序目的所需的数据成员。 这些数据成员是不同数据类型(例如int,float,double,char等)的基本C语言变量。

It is mandatory to add a semi-colon (;) after the closing curly bracket of a particular structure.

强制在特定结构的右花括号后添加分号(;)。

Example:

例:


struct Student_info
{ 
char name[100]; 
char address[100]; 
char division[50]; 
int roll_num; 
};

In the above code snippet, we have created a structure as Student_info to serve the purpose of Student Information. Within the structure, we have declared data members: name, address, division, and roll_num with their particular data type.

在上面的代码片段中,我们创建了一个名为Student_info的结构来满足学生信息的目的。 在结构中,我们声明了数据成员: nameaddressdivisionroll_num及其特定的数据类型



声明结构变量 (Declaration of Structure Variables)

Structur

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值