📜  c struct array - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:30.199000             🧑  作者: Mango

代码示例1
#include
#define n 3

struct Body //Normal struct definition
{
    double radius;
    double mass;
};

struct Body bodies[n]; //Declaration of Struct array

int main()
{
     for(int a = 0; a < n; a++)
     {
            bodies[a].mass = 0; //Access elements of struct array
            bodies[a].radius = 1.0;
     }

    return 0;
}