Error when looping

Hello,

When I run my code and it loops with the do-while loop because the user decided that the information he or she has entered was incorrect the code is somehow changed. When looping the code, the two main questions appear next to each other and the user is then only able to answer the second question. Could anyone please why the program would be acting this way?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
using namespace std;



int _tmain(int argc, _TCHAR* argv[])
{
	string title;
	string author;
		char incorrect;
		do
		{
			int strz;
				for (strz = 1; strz < 28; strz++)
				{
				cout << "*";
				}
		cout << "Automatic Book Finder";
			int strs;
				for (strs = 1; strs < 28; strs++)
				{
				cout << "*";
				}
		cout << endl; 				
					cout << "Please Enter Book Title: ";
						getline (cin, title);
					cout << "Please Enter Author: ";
						getline (cin, author); 
		cout << endl; 
				cout << "Title: " << title << endl;
				cout << "Author: " << author << endl;
		cout << "  \n";
				cout << "Is the information above entered correct? Lowercase y for Yes and n for No. \n";
				cin >> incorrect;
		}
		while (incorrect == 'n');

		cout << " end" << endl;

		system("pause");
		return 0;
}


There's a newline character hanging around after 'n' is input for incorrect at line 37. This is getting picked up as input for the title. Using cin.ignore() after the incorrect variable is read in is one way to handle this.
That worked great! Thank you.
Topic archived. No new replies allowed.