I am working on an assignment that I currently have. I am using cin.getline to input the title of a book. The problem is every time I run it here is how it shows up in the command prompt Title: Price: $_

Why is it doing this? cin.getline seems to be the only function that can read an entire line with spaces.

#include <iostream>
#include <iomanip>

using namespace std;

int main()

   const int SIZE = 25;
   char BookTitle[SIZE];

   int BookQuantity;

   double price;

   cout << "Enter book quanity" << endl;
   cin >> BookQuantity;

   cout << "Title: ";
   cin.getline(BookTitle, SIZE);

   cout << "Price: $";
   cin >> price;

return 0;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.