Home > Net >  What does the variable array name at the end of the structure's definition means?
What does the variable array name at the end of the structure's definition means?

Time:07-02

I've already read this, this and this but it seems they're not exactly my situtation.

I have a code like this

struct ppl_weight {
    uint16_t weight;
    uint8_t weightHour;

} ppl_weightList[16];

but I can't understand the array at the end of the struct. What does it mean? Have I an array of 16 struct? How does I manage this data type?

CodePudding user response:

It is a declaration of an array with 16 elements of the type struct ppl_weight. You could split this declaration

struct ppl_weight {
    uint16_t weight;
    uint8_t weightHour;

} ppl_weightList[16];

the following way

struct ppl_weight {
    uint16_t weight;
    uint8_t weightHour;

};

struct ppl_weight ppl_weightList[16];

CodePudding user response:

We can declare structure variables at the time of defining structure as follows

struct packet
{
  int range;
  char head;
}p1, p2, p3;
  • Related