使用typedef-C的结构中的结构

问题描述 投票:0回答:1

如何使用struct中的struct在另一个typedef中正确使用一个C

此方法无效,我不明白为什么:

#include <stdio.h>
#include <stdlib.h>

typedef struct
{
    char *nume;
    char *prenume;
    data data;
} student;

typedef struct
{
    int an,zi,luna;
} data;

int main()
{
    student Andrei;

    scanf("%s %s %d ",Andrei.nume,Andrei.prenume,&Andrei.b.an);
    printf("%s %s %d ",Andrei.nume,Andrei.prenume,Andrei.data.an);

    return 0;
}
c struct typedef
1个回答
0
投票

您的代码中实际上存在许多错误!

© www.soinside.com 2019 - 2024. All rights reserved.