Ok, help... lecture 23 ... AGAIN

Can someone Please tell me why this doesn’t work with #include

I keep getting an error on line 1… I’m trying to create my own function in the get a guess from the player section…

Here’s the code I have written so far…

#include
#include

using namespace std;

void PrintIntro();

//the entry point for our application
int main()
{
PrintIntro();

//get a guess from the player
{

string GuessOne = "";
string GuessTwo = "";
string GuessThree = "";
string GuessFour = "";
string GuessFive = "";
string GuessSix = "";
string GuessSeven = "";
string GuessEight = "";
string GuessNine = "";
string GuessTen = "";

cout << "Enter your first guess: ";
getline(cin, GuessOne);
// repeat the guess back to them look at 6:15 for screen below line 16
cout << "Your guess was: " << GuessOne << endl;

//get a guess from the player
cout << "Enter your second guess: ";
getline(cin, GuessTwo);
//repeat the guess back to them
cout << "Your second guess was: " << GuessTwo << endl;

cout << "Enter your third guess: ";
getline(cin, GuessThree);
cout << "Your third guess was: " << GuessThree << endl;

cout << "Enter your forth guess: ";
getline(cin, GuessFour);
cout << "Your forth guess was: " << GuessFour << endl;

cout << "Enter your fifth guess: ";
getline(cin, GuessFive);
cout << "Your fifth guess was: " << GuessFive << endl;

cout << "Enter your sixth guess: ";
getline(cin, GuessSix);
cout << "Your sixth guess was: " << GuessSix << endl;

cout << "Enter your seventh guess: ";
getline(cin, GuessSeven);
cout << "Your seventh guess was: " << GuessSeven << endl;

cout << "Enter your eighth guess: ";
getline(cin, GuessEight);
cout << "Your eighth guess was: " << GuessEight << endl;

cout << "Enter your ninth guess: ";
getline(cin, GuessNine);
cout << "Your ninth guess was: " << GuessNine << endl;

cout << "Enter your tenth and final guess: ";
getline(cin, GuessTen);
cout << "Your tenth guess was: " << GuessTen << endl;


cout << endl;
return 0;
}

void PrintIntro();
//introduce the game
constexpr int Word_Length = 9;
cout << "Welcome to Bulls and Cows, a fun word game.\n";
cout << "Can you guess the " << Word_Length;
cout << " letter isogram I'm thinking of?\n";
cout << endl;
return 0;

}

Hey,

From what I see above, you are using the preprocessor directive #include, but you are not including anything. You are making use of objects that require iostream and string.

#include <iostream>
#include <string>

Privacy & Terms