-
-
Save emberfox/373d6f88c9b3a7ed56fa8c29785debea to your computer and use it in GitHub Desktop.
Using getline problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main(void) | |
{ | |
// Introduce a game | |
constexpr int WORD_LENGTH = 5; | |
cout << "Welcome to Bulls and Cows \n"; | |
cout << "Can you guess the " << WORD_LENGTH; | |
cout << " letter isogram I'm thinking of?\n"; | |
cout << endl; | |
string Guess = ""; | |
// Get a guess from the player ---------------------------------------- | |
cout << "Enter your guess: "; | |
cin >> Guess; | |
// Repeat the guess back to them | |
cout << "You chose " << Guess << endl; | |
cout << endl; | |
//Ask and repeat 1 ---------------------------------------------------- | |
// Get a guess from the player | |
cout << "Enter your guess: "; | |
//string Guess = ""; | |
cin >> Guess; | |
// Repeat the guess back to them | |
cout << "You chose " << Guess << endl; | |
cout << endl; | |
//Ask and repeat 2 ---------------------------------------------------- | |
cout << "Enter your guess: "; | |
getline (cin, Guess); | |
cout << "You chose " << Guess << endl; | |
cout << endl; | |
//Ask and repeat 3 on getline =========================================== | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment