Struct containing arrays

Hi, With an Arduino Uno I'm having a problem that is probably simple to solve. I'm trying to get this code to print out "-30" but all I get is "0" no matter what value I put in "setpt[x]" in the serial.print line in loop().

    typedef struct
    {
      byte var1[12];
      int  var2[12];
      byte var3[12];
 
    }record_type;

    record_type profile[8];

    void setup()
    {
      Serial.begin(9600);
      Serial.println("*** START ***");
    }
    
    void loop()
    {
      profile[0] = (record_type) {(1,2,3),(-40,-30,-25),(1,2,3),};
      
      Serial.println(profile[0].var2[1]);
    
    }

This sets only the first element of each array in your struct (with values 1, -40, and 1), leaving the remaining elements set to zero. Change the parentheses to braces inside the braces (with parentheses instead of braces, each expression evaluates to a single value—the commas are actually comma operators).

Thanks ! that worked. profile[0] = (record_type) { {1,2,3} , {-40,-30,-25} , {1,2,3} };

Why the cast to record_type when the struct is declared to be of that type anyway ?

I see what you mean. I'm fairly new to this and just followed an example. Thanks for the hint.