title: How to print data from a structure in a loop
body: <p>I want a loop that prints the values for each soda.
  When I try to print <code>machine[j].name</code>, an error is thrown stating that no operator is found or no acceptable conversion exists.</p>
  
  <pre><code>struct Soda
  {
      string name;
      double price;
      int quantity;
  } a, b, c, d, e;
  
  int main(int argc, char** argv)
  {
      Soda machine[5];
      a.name = "Cola";
      a.price = .80;
      a.quantity = 20;
      b.name = "Root Beer";
      b.price = .75;
      b.quantity = 20;
      c.name = "Lemon-Lime";
      c.price = .90;
      c.quantity = 20;
      d.name = "Grape - Mango";
      d.price = .80;
      d.quantity = 20;
      e.name = "Cream";
      e.price = .80;
      e.quantity = 20;
  
      cout &lt;&lt; setw(5) &lt;&lt; "  Name" &lt;&lt; setw(15) &lt;&lt; " Cost"
          &lt;&lt; setw(15) &lt;&lt; " Stock" &lt;&lt; setw(14) &lt;&lt; "";
      for (int i = 0; i &lt; 5; i++)
          for (int j = 0; j &lt; 3; j++){
              cout &lt;&lt; left &lt;&lt; setw(5) &lt;&lt; machine[j].name
                   &lt;&lt; setw(15) &lt;&lt; " Cost" &lt;&lt; setw(15) &lt;&lt; " Stock"
                   &lt;&lt; setw(14);
      return 0;
  }
  </code></pre>