Basically my program lets the users ask a question, picks a number and then the computer "Tells the future". I want to put in file that allows the user to "cheat" if they agree to it and let them know the numbers of the respones. But I can't get the file to open when they say yes. I bolded what I tried to input the file
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <fstream>usingnamespace std;
int main() {
int inNum;
int n;
string x = "y";
string question="";
string answers[8] = {
"No",
"Yes",
"Your guess is as good as mine",
"It looks like there's a chance",
"If you believe anything is possible",
"Try again","Give me another one","I believe it's your lucky day"
};
while ( tolower(x[0]) == 'y' ) {
cout << "Ask me a question and I'll tell you the future" << endl;
getline (cin, question);
ifstream future;
bool fromFile;
string s;
cout << "Play from file (y/n)?";
cin >> s;
if (s == "y") {
history.open("future.txt");
fromFile = true;
}
else fromFile = false;
cout << "Choose between 1-8 or type 9 for random:" << endl;
cin >> inNum;
cin.ignore();
n = inNum;
if ( n==9 )
{
srand(time(NULL));
n = rand() % 8 + 1; }
if ( n > 0 and n < 9 ){ cout << answers[n-1] << endl; }
if ( n > 9 ){ cout << "That's not between 1-9!" << endl;
}
cout << "Do you want to play again?" << endl;
cin >> x;
cin.ignore();
}
future.close();return 0;
}