#include #include #include using namespace std; void OpenFile(ifstream & file); void GetBlank(string & result, ifstream & file); void ProcessLine(void); void Introduction(string lineA, string lineB, string lineC, string lineD); int main() { ifstream inFile; string blank1, blank2, blank3, blank4; string line; // open the file OpenFile(inFile); // read the four blank values from the file GetBlank(blank1, inFile); GetBlank(blank2, inFile); GetBlank(blank3, inFile); GetBlank(blank4, inFile); if (inFile) { Introduction(blank1, blank2, blank3, blank4); } // tell the story getline(inFile, line); while (inFile) { cout << line << endl; ProcessLine(); getline(inFile, line); } return 0; } void OpenFile(ifstream & file){ string fileName; bool fileOpen = false; while (not fileOpen) { cout << "Enter the name of a madlib file => "; cin >> fileName; cin.ignore(100,'\n'); cout << endl; cout << "Attempting to open " << fileName << endl; file.open(fileName.c_str()); if (file) { cout << "Success " << endl; fileOpen = true; } else { cout << "Unable to open " << fileName << endl; } cout << endl << endl; } return; } void GetBlank(string & result, ifstream & file){ string description; char answer; bool goodAnswer = false; getline(file, description); if (file) { while (not goodAnswer) { cout << "Enter " << description << " => "; getline(cin, result); cout << "You said that " << result << " was " << description << endl; cout << "Is this ok? (Y,N) => "; cin >> answer; cin.ignore(100,'\n'); answer = toupper(answer); if (answer == 'Y') { goodAnswer = true; } } cout << endl; } return; } void ProcessLine(void){ cout << "In Process Line" << endl; return; } void Introduction(string lineA, string lineB, string lineC, string lineD) { cout << endl; cout << "We will now tell a story about " << lineA << ", " << lineB << ", " << lineC << " and " << lineD << endl; cout << endl; return; }