I have a struct that contains a field that is an array of 7 cells and I want to define the values of the cells quickly and easily.
Is there a way to easily and quickly declare and define an array such as with this manner ?
struct my_struct
{
uint8_t array[7];
}
struct my_struct var = {0};
memcpy(var.array, (uint8_t){0,1,2,3,4,5,6}, 7);
Or this way ?
struct my_struct
{
uint8_t array[7];
}
struct my_struct var = {0};
var.array = (uint8_t)[]{0,1,2,3,4,5,6};
Or I must do this way ?
struct my_struct
{
uint8_t array[7];
}
struct my_struct var = {0};
var.array[0] = 0;
var.array[1] = 1;
var.array[2] = 2;
var.array[3] = 3;
var.array[4] = 4;
var.array[5] = 5;
var.array[6] = 6;
Thank you ;)