如何访问结构中的结构数组
how to access array of structure within a structure
struct students
{
char name[256];
int Roll_number;
};
struct colleges
{
char name[256];
Student students[100];
};
如何访问学生[0].name,我尝试使用 -> 和 .运营商是不可访问的
#include <stdio.h>
struct students {
char name[256];
int Roll_number;
};
struct colleges {
char name[256];
struct students students[100];
};
int main(void)
{
struct colleges c = { };
printf("%s\n", c.students[0].name);
return 0;
}
结构中的结构:嵌套结构
- 写在另一个结构中的结构称为两个结构的嵌套。
- C 编程语言允许嵌套结构。
- 我们可以在另一个结构中编写一个结构作为另一个结构的成员。
作为另一个结构的成员
struct students
{
char name[256];
int Roll_number;
};
struct colleges
{
char name[256];
Student students[100];
};
如何访问学生[0].name,我尝试使用 -> 和 .运营商是不可访问的
#include <stdio.h>
struct students {
char name[256];
int Roll_number;
};
struct colleges {
char name[256];
struct students students[100];
};
int main(void)
{
struct colleges c = { };
printf("%s\n", c.students[0].name);
return 0;
}
结构中的结构:嵌套结构
- 写在另一个结构中的结构称为两个结构的嵌套。
- C 编程语言允许嵌套结构。
- 我们可以在另一个结构中编写一个结构作为另一个结构的成员。
作为另一个结构的成员