struct store
{
...
struct item
{
...
}it[];
struct employee
{
...
}e[];
}s[];
这里我想知道在获取结构项的输入后存储了多少项
最佳答案
对于无界数组,C 没有“数组大小”的概念。事实上,它的数组概念充其量是摇摇欲坠的。
通常使用的两个选项是:
- 在数组旁边存储一个“长度”属性
- 以零结束数组,即最后一个元素之后的指针为零
对于您的情况,我推荐两者中的第一个:
struct mydatastruct
{
int store_length;
struct store
{
...
int item_length;
struct item
{
...
} it[];
int employee_length;
struct employee {
...
} e[];
} s[];
} mystruct;
关于c - 我想获取嵌套的 unsizes 结构数组中的项目数。我该怎么做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36018210/