C 语言 结构类型 结构

int main (int argc, char const *argv[])
{
struct date {
int moth;
int day;
int year;
};

    struct date today;

    today.month = 07;
    today.day =  31;
    today.year = 2014;
}

声明结构体的形式

1 struct point {
    int x;
    int y;
};
struct point p1, p2;
p1 和p2 都是point,里面有x和y的值

2 struct {
    int x;
    int y;
} p1, p2;
p1 和 p2 都是一种无名结构,里面有x和y

3 也是最常见的
struct point {
    int x;
    int y;
} p1, p2;
p1和p2 都是point,里面有x和y的值

结构数组

struct date dates[100]
含100个struct date的数组
struct date dates[] = {
 {4,5,2005}, {2,4,2005}};  可用dates[i].  获得每个数组项中的结构成员



note; 结构类型和结构变量时两件事情

结构的初始化

sturct date today = { 07, 31, 2014};
struct date thismonth = { .month =7, .yesr = 2014};
posted on 2019-05-22 08:10 DemonMaster 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/DemonMaster/p/10903689.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值