title: There was a red line showing expression must be a modifiable lvalue error under the struct of array line
body: <p>DATA forex[] is my struct of array. I'm trying to assign the answer of the equation (price/time_frame) into my forex[i].SMA. time_frame is another value that i got through user input from another function that i did not show here. But there was an error that i do not understand. There was a red line showing expression must be a modifiable lvalue error under the forex[i].SMA</p>
  
  <pre><code>void calculate_SMA(int time_frame, int count, DATA forex[])
  {
      double sma, price_total;
      for (int j = time_frame - 1; j &lt; count; j++)
      {
          price_total = 0.0;
  
          for (int i = 0; i &lt; i + time_frame; i++)
              price_total += forex[i].price;
  
          forex[j].SMA = price_total / time_frame;
          cout &lt;&lt; forex[j].SMA &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>this is the typedef struct</p>
  
  <pre><code>typedef struct
  {
      char date[11];
      double price;
      double SMA;
      double EMA;
  }DATA;
  </code></pre>