ini file output?
Mar 20, 2013 at 8:32am UTC
so i have this tic tac toe game ive gotten it all to work perfectly but the last part is to get how many wins, loses and ties output on console and save to a t3.ini file i think i did it right but cant find the t3 file in my c:/ ? please help
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
while ((playAgain == 'Y' ) || (playAgain == 'y' ))
{
cout << endl;
cout << " Choose your opponent! \n" ;
cout << " You have 3 options, please select # (1-3): \n" ;
cout << endl;
cout << " 1: Human Opponent \n" ;
cout << " 2: Dumb Computer Player \n" ;
cout << " 3: Smart Computer Player \n" ;
cout << endl;
cout << "Please enter your selection: " ;
cin >> opponent;
cout << endl;
char grid[] = {' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' };
printGrid(grid);
goX(grid);
printGrid(grid);
while (1)
{
if (check4Xwinner(grid) == 'Y' )
{
printGrid(grid);
cout << endl;
cout << "X's is the winner! \n" ;
cout << endl;
xWins++;
break ;
}
// Checks if tie
if (check4Tie(grid) == 'Y' )
{
printGrid(grid);
cout << endl;
cout << "It's a tie.... \n" ;
cout << endl;
tie++;
break ;
} // end if
// O moves. Specific player that moves is selected by user
switch (opponent)
{
case 1: // Human
printGrid(grid);
goO1(grid);
printGrid(grid);
goX(grid);
printGrid(grid);
break ;
case 2: // Dumb computer
printGrid(grid);
goO2(grid);
printGrid(grid);
goX(grid);
printGrid(grid);
break ;
case 3: // Smart computer
printGrid(grid);
goO3(grid);
printGrid(grid);
goX(grid);
printGrid(grid);
break ;
} // end switch
// Checks if O is winner
if (check4Owinner(grid) == 'Y' )
{
cout << endl;
cout << "O's is the winner! \n" ;
cout << endl;
oWins++;
break ;
} // end if
} // end while
cout << "Would you like to play the game again? [Y/N]: " ;
cin >> playAgain;
if (playAgain == 'N' || playAgain == 'n' )
cout << endl;
cout << "Results of games played \n" ;
cout << endl;
cout << "You won: " << xWins << " times! \n" ;
cout << "Your opponent won: " << oWins << " times... \n" ;
cout << "You tied: " << tie << " times. \n" ;
cout << endl;
ofstream fout;
fout.open ("T3.ini" , std::fstream::fout|std::fstream::trunc);
fout << xWins << endl;
fout << oWins << endl;
fout << tie << endl;
} // end second while
fout.close();
Mar 20, 2013 at 10:29am UTC
It would be in your project folder.
Mar 23, 2013 at 10:31pm UTC
so theres nothing wrong with the code?
Topic archived. No new replies allowed.