king110_1 2021-09-28 20:53 采纳率: 25%
浏览 13

ae问下,怎么用循环把结构体元素输出

比如我定义了一个结构体

struct head
{
char s[10]
int n;
int i[20];
byte k;
byte b[50];
}
for(int x=0;x<5;x++)
{
printf();
//怎么填写
}

  • 写回答

2条回答 默认 最新

  • 关注

    创建一个对象h,用h.xxx输出它的属性

    #include <stdio.h>
    #include <stdlib.h>
    struct head
    {
    char s[10]="asd";
    int n=1;
    int i[20];
    
    }h;
    
    int main()
    {
        printf("%s",h.s);
    
    return 0;
    }
    

    img

    评论

报告相同问题?

问题事件

  • 创建了问题 9月28日