gpt4 book ai didi

c - 使用 C 的嵌套结构程序

转载 作者:太空宇宙 更新时间:2023-11-04 08:18:19 24 4
gpt4 key购买 nike

<分区>

我的嵌套结构程序发送错误。

这里我使用了两个结构。

#include <stdio.h>

void main()
{
struct time
{
int min;
int hour;
int sec;
};

struct t
{
int c;
struct time t1;
struct time t2;
}p;

scanf("%d", &p.c);
scanf("%d%d%d", &p.t1.minute, &p.t1.hour, &p.t1.second);
scanf("%d%d%d", &p.t2.minute, &p.t2.hour, &p.t2.second);

printf("%d%d%d", p.p1.min, p.p1.hour, p.p1.sec);
printf("%d%d%d", p.p2.min, p.p2.hour, p.p2.sec);
}

运行此代码后出现以下错误。

struct time’ has no member named ‘minute’
nested.c:17: error: ‘struct time’ has no member named ‘second’
nested.c:18: error: ‘struct time’ has no member named ‘minute’
nested.c:18: error: ‘struct time’ has no member named ‘second’

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com