Answers for "create array of structs in c"

1

c struct array

#include<stdio.h>
#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;
}
Posted by: Guest on April-13-2021
0

create array of structs cpp

Customer::Customer(int id, string input_name): uid(id), name(input_name) {}
Customer customerRecords[2];
customerRecords[0] = Customer(25, "Bob Jones");
custoemrRecords[1] = Customer(26, "Jim Smith");
Posted by: Guest on October-08-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language