我需要在使用类似这样的结构时创建一个人员数组:-
typedef struct Person
{
int age; //needs to be randomly generated
int height; //needs to be randomly generated
int weight; //needs to be randomly generated
} Person;
但我不知道如何使用像这样的数组来做到这一点:-
人[0]
人[1]
人[2]
任何提示都会很棒!!
最佳答案
typedef struct Person
{
int age; //needs to be randomly generated
int height; //needs to be randomly generated
int weight; //needs to be randomly generated
} Person;
// Create an array of 5 Persons
Person persons[5];
// Set the data of the first person.
person[0].age = 25;
person[0].height = 175; // in cm
person[0].weight = 68; // in kg
关于c - 一群人在 c 中使用结构体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23351453/