Structure Array Initialization I'm trying to initialize a char array which is part of a structure as follows:

#define TRUE 1
#define FALSE 0

struct s_field_def { // structure for managing display field
  char f_txt[16]; // option text
  bool f_inhibit; // set this to inhibit updating of the field on the display
};

enum field_name {F_STATE, F_PULSE};

void setup() {

  // initialize display fields structure
  struct s_field_def fields[2]; // initialize the display fields
  fields[F_STATE] =  {"HALTED", FALSE}; // displays the current run state
  fields[F_PULSE] =  {"@", TRUE}; // displays indicator of system running   
}

void loop() {

}


The initialization of the structure is producing an error at these lines:

  fields[F_STATE] =  {"HALTED", FALSE}; // displays the current run state
  fields[F_PULSE] =  {"@", TRUE}; // displays indicator of system running   

no match for 'operator=' (operand types are 's_field_def' and '&lt;brace-enclosed initializer list&gt;')


What am I doing wrong here?
As explained in Michel Keijzers' answer, you cannot use the = operator
to assign something to a string (a character array). However, you can
initialize a string using =. There is an important distinction
between assignment, which you can do anywhere in a program, an
initialization, which can only be done at the time you define a
variable.

For example:



int i = 2;  // initialization

void setup() {
    i = 4;  // assignment
}


In your specific case, you can initialize fields as follows:

struct s_field_def fields[2] = {
    {"HALTED", FALSE},  // displays the current run state
    {"@", TRUE}         // displays indicator of system running   
};