may i know what is wrong with this code?
Aug 28, 2012 at 9:07pm UTC
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
void bejeweled::loadGame(int & score, int & LIFE){
reallocateMemory();
char temp;
int num, num2;
ifstream outfile;
outfile.open("board.txt" );
if (outfile.is_open()){
for (int i=0; i<64; i++){
outfile>>temp;
array[i] = temp;
}
for (int i=0; i<64; i++){
cout << array[i];
}
cout << endl;
}
outfile.close();
outfile.clear();
outfile.open("score.txt" );
score = outfile>>num;
outfile.close();
outfile.clear();
outfile.open("life.txt" );
LIFE = outfile>>num2;
cout << "Game Loaded\n" ;
system("pause" );
}
the score = outfile>>num and LIFE = outfile>>num2 gives this error;
error: invalid conversion from void* to int
what does the error means? how do i fix it?
Aug 28, 2012 at 10:47pm UTC
What is it?
score = outfile>>num;
Aug 28, 2012 at 11:21pm UTC
score and LIFE is initialize in main, it's
int score = 0;
int LIFE = 3;
Aug 28, 2012 at 11:24pm UTC
The type of the expression outfile>>num is std::ifstream. You are trying to assign a value of this type to object score of type int.
Why are you using variables num and num2? What for?!
You can simply write
1 2 3
outfile >> score;
.....
outfile >> LIFE;
Last edited on Aug 28, 2012 at 11:27pm UTC
Aug 28, 2012 at 11:32pm UTC
ic, i understand now, thanks :)
Topic archived. No new replies allowed.