Problem with Game???

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 #include <iostream>
 #include <stdlib.h>
 #include <string.h>
 #include <fstream>
 using namespace 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;

}



Thanks!
Last edited on
Topic archived. No new replies allowed.