title: If string does not equal const char break out of while loop
body: <p>I'm having a problem breaking out of this while loop in my code. If the user is done entering items I want them to press q to exit. This does not work, q gets entered by the user and the loop is not broken. If there is also a better way to do this that would be great.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "CashRegister.h"
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  CashRegister::CashRegister(void)
  {
  }
  
  CashRegister::~CashRegister(void)
  {
  }
  
  void CashRegister::addItem(void)
  {
  string temp;
  int k = 0;
  int exit = 0;
  CashRegister item[10];
  
  for(int i = 0; i &lt; 10; ++ i)
  {
      item[i].price = 0.00;
  }
  
  cout &lt;&lt; "Enter price of items. Up to 10 maximum\n" &lt;&lt; endl;
  
  while(item[9].price != 0.00 || temp != "q")
  {
      cout &lt;&lt; "Enter price of item number " &lt;&lt; k + 1 &lt;&lt; "\n" &lt;&lt; endl;
      cin &gt;&gt; temp;
      cout &lt;&lt; temp &lt;&lt; endl;
      double tempPrice = (double)atof(temp.c_str());
      item[k].price = tempPrice;
      cout &lt;&lt; "Price of item number " &lt;&lt; k + 1 &lt;&lt; " is $" &lt;&lt; item[k].price &lt;&lt; endl;
      ++k;
  }
  </code></pre>
  
  <p>}</p>