title: Create an array of structure using new
body: <p>I have some difficult situation here which I hope some body will help me.</p>
  
  <p>I have the following,</p>
  
  <pre><code>struct CandyBar{ 
    std::string name; 
    double weight; 
    int calories; 
  } ;
  </code></pre>
  
  <p>Now, for creating an array of structure to contain  many CandyBars is much simple which I have done like;</p>
  
  <pre><code>int main(){
     CandyBar bars[] = {{"Mango tart", 2.3, 100}, {"Yo Yo", 3.2, 130}, {"Orange Ball", 1.7, 98}};
    return 0;
  }
  </code></pre>
  
  <p>But, now I want to create the same structure using new. It is quite simple when I think it but this crashes and does not work.</p>
  
  <pre><code>CandyBar *bars = new CandyBar;
    (*bars).name = "Mango tart";
     bars-&gt;weight =  2.3;
     bars-&gt;calories =  100;
     bars += 1;
  
    (*bars).name = "Yo Yo";
    bars-&gt;weight =  3.2;
    bars-&gt;calories =  130;
  
    bars += 1;
    (*bars).name =  "Orange Ball";
    bars-&gt;weight =  1.7;
    bars-&gt;calories =  98; 
  </code></pre>
  
  <p>But, this does not work. As I think that the first pointer is a memory location pointing to the first structure and then I create the structure and then increase the address using bar += 1, and go on creating the pointer but am I missing something really serious.</p>
  
  <p>I would really appreciate your help.</p>