getline function

In my program I am trying to cin a book title and have it search my book.txt document for the book. However I cannot get my function to cin the whole title without spaces.

Below is my function and code any help would be appreciated.

Function:
void titleInfo(Book* books, int numBooks, string& query)
{
cout << "search string = " << query << endl;
for (int i = 0; i < query.length(); ++i)
{
Book& current = books[i];
if (current.getTitle() == query)
current.print();
}
}


Cin CODE
cout << "Enter Book Title: " << endl;
//cin >> input;
getline(cin, input);
cout << "Book Title Input= "<< input << endl;
titleInfo(mybooks, numBooks, input);
However I cannot get my function to cin the whole title without spaces.
What is actual problem? Does it crash? Does it not read past space? Does it seemingly skips input and reads an emty string? In this case: http://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction
Topic archived. No new replies allowed.