By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,798 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,798 IT Pros & Developers. It's quick & easy.

Problem with input

P: n/a
nrm
Ho, I'm having a problem when I run the following code, and enter the
name of the first candidate, after I press enter, the program skips the
chance to enter the second candidate's name. Anybody know a solution?
Thanks.

std::cout << "Please enter the name of the first candidate: ";
std::cin >> NameOne;
std::cout << "Please enter the name of the second candidate: ";
std::cin >> NameTwo;

Dec 24 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

nrm wrote in message
<11**********************@g49g2000cwa.googlegroups .com>...
Ho, I'm having a problem when I run the following code, and enter the
name of the first candidate, after I press enter, the program skips the
chance to enter the second candidate's name. Anybody know a solution?
Thanks.

std::cout << "Please enter the name of the first candidate: ";
std::cin >> NameOne;
// try (remove the [return] from the stream):
std::cin.ignore();
std::cout << "Please enter the name of the second candidate: ";
std::cin >> NameTwo;


--
Bob R
POVrookie
Dec 24 '05 #2

P: n/a
BobR <Re***********@worldnet.att.net> wrote:

nrm wrote in message
<11**********************@g49g2000cwa.googlegroups .com>...
Ho, I'm having a problem when I run the following code, and enter the
name of the first candidate, after I press enter, the program skips the
chance to enter the second candidate's name. Anybody know a solution?
Thanks.

std::cout << "Please enter the name of the first candidate: ";
std::cin >> NameOne;


// try (remove the [return] from the stream):
std::cin.ignore();
std::cout << "Please enter the name of the second candidate: ";
std::cin >> NameTwo;


Also, if the name has spaces in it, you may want to look into using
std::getline()

--
Marcus Kwok
Jan 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.