title: C++ - String input with a pointer-to-structure?
body: <p>How do you use a pointer-to-struct to get input that will be stored in a string variable? I thought simply passing pz->szCompany to getline() would behave the same as if I had used the . operator on a normal instance of Pizza (instead of a pointer-to), but when I run this program it skips over the company name prompt completely.</p>
  
  <pre><code>// Parts of the program omitted.
  struct Pizza {
      string szCompany;
      float diameter;
      float weight;
  };
  Pizza* pz = new Pizza;
  
  cout &lt;&lt; "Enter the weight: ";
  cin &gt;&gt; pz-&gt;weight;
  
  cout &lt;&lt; "Enter the company name: ";
  // use getline because the company name can have spaces in it.
  getline(cin, pz-&gt;szCompany);
  
  cout &lt;&lt; "Enter the diameter: ";
  cin &gt;&gt; pz-&gt;diameter;
  
  cout &lt;&lt; "\nCompany name: " &lt;&lt; pz-&gt;szCompany;
  cout &lt;&lt; "\nWeight: " &lt;&lt; pz-&gt;weight;
  cout &lt;&lt; "\nDiameter: " &lt;&lt; pz-&gt;diameter;
  
  // cannot forget this step.
  delete pz;
  return 0;
  </code></pre>