title: C++ cin keeps skipping
body: <p>I am having problems with my program. WHen I run it, it asks the user for the album, the title, but then it just exits the loop without asking for the price and the sale tax. Any ideas what's going on?</p>
  
  <p>This is a sample run</p>
  
  <pre>
  Discounts effective for September 15, 2010
  Classical   8%
  Country 4%
  International   17%
  Jazz    0%
  Rock    16%
  Show    12%
  Are there more transactions? Y/N
  y
  Enter Artist of CD: 
  Sevendust
  Enter Title of CD: 
  Self titled
  Enter Genre of CD: 
  Rock
  enter price
  Are there more transactions? Y/N
  Thank you for shopping with us!
  </pre>
  
  <p>Program code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #include &lt;string&gt;
  
  
  
  using namespace std;
  
  
  
  int counter = 0;
  
  string discount_tiles[] = {"Classical", "Country", "International", "Jazz", "Rock", "Show"};
  
  int discount_amounts[] = {8, 4, 17, 0, 16, 12, 14};
  
  string date = "September 15, 2010";
  
  
  
  // Array Declerations
  
      //Artist array
  
      char** artist = new char *[100];        
  
      //Title array
  
      char** title = new char *[100]; 
  
      //Genres array
  
      char** genres = new char *[100];
  
      //Price array
  
      double* price[100]; 
  
      //Discount array
  
      double* tax[100];
  
      // sale price array
  
      double* sale_price[100];    
  
      //sale tax array
  
      double* sale_tax[100];  
  
      //cash price array
  
      double* cash_price[100];    
  
  
  
  //Begin Prototypes
  
  char* getArtist();
  
  char* getTitle();
  
  char* getGenre();
  
  double* getPrice();
  
  double* getTax();
  
  unsigned int* AssignDiscounts();
  
  void ReadTransaction (char ** artist, char ** title, char ** genre, float ** cash, float &amp; taxrate, int albumcount);
  
  void computesaleprice();
  
  
  
  
  
  bool AreThereMore ();
  
  
  
  //End Prototypes
  
  
  
  bool areThereMore ()
  
  {   
  
      char answer;
  
      cout &lt;&lt; "Are there more transactions? Y/N" &lt;&lt; endl;
  
      cin &gt;&gt; answer;
  
      if (answer =='y' || answer =='Y')
  
          return true;
  
      else 
  
          return false;
  
  }
  
  
  
  char* getArtist()
  
  {
  
      char * artist= new char [100];
  
      cout &lt;&lt; "Enter Artist of CD: " &lt;&lt; endl;
  
      cin.getline(artist,100);
  
      cin.ignore();
  
      return artist;
  
  }
  
  
  
  char* getTitle()
  
  {
  
      char * title= new char [100];
  
      cout &lt;&lt; "Enter Title of CD: " &lt;&lt; endl;
  
      cin.getline(title,100);
  
      cin.ignore();
  
      return title;
  
  }
  
  
  
  char* getGenre()
  
  {
  
      char * genre= new char [100];
  
      cout &lt;&lt; "Enter Genre of CD: " &lt;&lt; endl;
  
      cin.getline(genre,100);
  
      cin.ignore();
  
      return genre;
  
  }
  
  
  
  double* getPrice()
  
  {   
  
      //double* price = new double();
  
      //cout &lt;&lt; "Enter Price of CD: " &lt;&lt; endl;
  
      //cin &gt;&gt; *price;
  
  
  
      //return price;
  
  
  
      double p = 0.0;
  
      cout&lt;&lt; "enter price" &lt;&lt; endl;
  
      cin &gt;&gt; p;
  
      cin.ignore();
  
      double* pp = &amp;p;
  
      return pp;
  
  }
  
  
  
  double* getTax()
  
  {
  
      double* tax= new double();
  
      cout &lt;&lt; "Enter local sales tax: " &lt;&lt; endl;
  
      cin &gt;&gt; *tax;
  
  
  
      return tax;
  
  }
  
  
  
  int findDiscount(string str){
  
  
  
      if(str.compare(discount_tiles[0]) == 0)
  
          return discount_amounts[0];
  
      else if(str.compare(discount_tiles[0]) == 0)
  
          return discount_amounts[1];
  
      else if(str.compare(discount_tiles[0]) == 0)
  
          return discount_amounts[2];
  
      else if(str.compare(discount_tiles[0]) == 0)
  
          return discount_amounts[3];
  
      else if(str.compare(discount_tiles[0]) == 0)
  
          return discount_amounts[4];
  
      else if(str.compare(discount_tiles[0]) == 0)
  
          return discount_amounts[5];
  
      else{
  
          cout &lt;&lt; "Error in findDiscount function" &lt;&lt; endl;
  
          return 0;
  
      }
  
  }
  
  
  
  void computesaleprice()
  
  {
  
      /** fill in array for all purchases **/
  
      for( int i=0; i&lt;=counter; i++){
  
          double temp = *price[i];
  
          temp -= findDiscount(genres[i]);
  
          double* tmpPntr = new double();
  
          tmpPntr = &amp;temp;
  
          sale_price[i] = tmpPntr;
  
          delete(&amp;temp);
  
          delete(tmpPntr);
  
      }
  
  }
  
  
  
  
  
  
  
  
  
  
  
  void printDailyDiscounts(){
  
      cout &lt;&lt; "Discounts effective for " &lt;&lt; date &lt;&lt; endl;
  
      for(int i=0; i &lt; 6; i++){
  
          cout &lt;&lt; discount_tiles[i] &lt;&lt; "\t" &lt;&lt; discount_amounts[i] &lt;&lt; "%" &lt;&lt; endl;
  
      }
  
  }
  
  
  
  //Begin Main
  
  int main ()
  
  {
  
  
  
  
  
  
  
      for( int i=0; i&lt;100; i++){
  
          artist[i]=new char [100];
  
          title[i]=new char [100];
  
          genres[i]=new char [100];       
  
          price[i] = new double(0.0);
  
          tax[i] = new double(0.0);
  
      }
  
  
  
      // End Array Decleration
  
  
  
      printDailyDiscounts();
  
  
  
      bool flag = true;   
  
      while(flag == true){
  
          if(areThereMore() == true){
  
              artist[counter] = getArtist();
  
              title[counter] = getTitle();
  
              genres[counter] = getGenre();
  
              price[counter] = getPrice();
  
              //tax[counter] = getTax();          
  
              //counter++;
  
              flag = true;
  
          }
  
          else {
  
              flag = false;
  
          }
  
      }
  
  
  
  
  
      //compute sale prices
  
      //computesaleprice();
  
  
  
  
  
  
  
  
  
  
  
  
  
      cout &lt;&lt; "Thank you for shopping with us!" &lt;&lt; endl;
  
  
  
      return 0;
  
  }
  
  //End Main
  
  
  
  
  
  
  
  
  
  
  
  
  
  /**
  
  void ReadTransaction (char ** artist, char ** title, char ** genre, float ** cash, float &amp; taxrate, int albumcount)
  
  {
  
      strcpy(artist[albumcount],getArtist());
  
      strcpy(title[albumcount],getTitle());
  
      strcpy(genre[albumcount],getGenre());
  
      //cash[albumcount][0]=computesaleprice();???????
  
      //taxrate=getTax;??????????????
  
  
  
  
  
  }
  
  * 
  
  * */
  
  
  
  
  
  
  
  unsigned int * AssignDiscounts()
  
  {
  
      unsigned int * discount = new unsigned int [7];
  
      cout &lt;&lt; "Enter Classical Discount: " &lt;&lt; endl;
  
      cin &gt;&gt; discount[0];
  
      cout &lt;&lt; "Enter Country Discount: " &lt;&lt; endl;
  
      cin &gt;&gt; discount[1];
  
      cout &lt;&lt; "Enter International Discount: " &lt;&lt; endl;
  
      cin &gt;&gt; discount[2];
  
      cout &lt;&lt; "Enter Jazz Discount: " &lt;&lt; endl;
  
      cin &gt;&gt; discount[3];
  
      cout &lt;&lt; "Enter Pop Discount: " &lt;&lt; endl;
  
      cin &gt;&gt; discount[4];
  
      cout &lt;&lt; "Enter Rock Discount: " &lt;&lt; endl;
  
      cin &gt;&gt; discount[5];
  
      cout &lt;&lt; "Enter Show Discount: " &lt;&lt; endl;
  
      cin &gt;&gt; discount[6];
  
      return discount;
  
  }
  
  
  
  /**
  
  char ** AssignGenres ()
  
  {
  
      char ** genres = new char * [7];
  
      for (int x=0;x&lt;7;x++)
  
          genres[x] = new char [20];
  
      strcpy(genres [0], "Classical");
  
      strcpy(genres [1], "Country");
  
      strcpy(genres [2], "International");
  
      strcpy(genres [3], "Jazz");
  
      strcpy(genres [4], "Pop");
  
      strcpy(genres [5], "Rock");
  
      strcpy(genres [6], "Show");
  
      return genres;
  
  }
  
  **/
  
  
  
  
  
  
  
  float getTax(float taxrate)
  
  {
  
      cout &lt;&lt; "Please enter store tax rate: " &lt;&lt; endl;
  
      cin &gt;&gt; taxrate;
  
      return taxrate;
  
  }
  </code></pre>