本文介绍了Tic tac toe功能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿!!我正在使用类进行tic tac toe游戏,我完全用它完成但是使用保存游戏和加载游戏功能存在问题我在保存游戏中遇到错误,我只想用二进制文件保存游戏使用文件i / o和我读到它,但我找不到足够的关于它!我想破坏你宝贵的一些时间,(不要介意)!!我被困在需要紧急帮助!!这就是我做的事情我尝试过的事情:
#include< iostream>
#include< fstream>
//#include< cstdlib>
using namespace std;
class tic
{
private:
static char table []; //静态变量启动要求所以最后我启动kiya hua hay class say bahar
int i,选择; //局部变量jo code me istimaal hon gay
char spot;
静态字符重放; //相同oper wala case
static int player; //相同oper wala case
void board()// board bana rahy hein jahan pey hum isko khelna chahty hein
cout<< \\ t \\ t \\ t \\ t \\ t \\ t \\ t \\ ttt Tac Toe \\\\\\\ n
cout<< \t \t \t球员1(X),球员2(O)\ n \\ n;
cout<< \t \t \t<<表[1]<< | <<表[2]<< | <<表[3]<< endl; //数组ki位置零支付jo值hogi usko插入kar day ga类似agay bhi
void Save_Game(char board [3] [3])
{
int i;
FILE * savegame = fopen(save.bin,w);
for(i = 0; i< 3; i ++)
{
fprintf(savegame,%c%c%c\ n,board [i] [0], board [i] [1],board [i] [2]);
}
fclose(savegame);
cout<< 游戏已保存;
}
int win()
{
if(table [1] = = table [2]&& table [2] == table [3])
返回1;
else if(table [4] == table [5]&& table [5] == table [6])
return 1;
//////////
解决方案
hey !! i am doing tic tac toe game using classes and i am completely done with it but there is problem with it using the save game and load game function i am getting error in save game , i just want to save game in binary file using file i/o and i read about it, but i couldn't found enough about it !! i want to ruin some of your precious time, (Don't Mind) !! i am stuck in it need urgent help !!here is what i do
What I have tried:
#include<iostream> #include<fstream> //#include<cstdlib> using namespace std; class tic { private: static char table[];//static variable initilization require so last me initilize kiya hua hay class say bahar int i, choice;//local variables jo code me istimaal hon gay char spot; static char replay;//same oper wala case static int player;//same oper wala case
void board()//board bana rahy hein jahan pey hum isko khelna chahty hein
cout << "\t \t \t \t Tic Tac Toe\t\t\n\n"; cout << "\t \t \t PLAYER 1(X) , PLAYER 2(O)\n\n"; cout << "\t \t \t " << table[1] << "|" << table[2] << "|" << table[3] << endl;//array ki location zero pay jo value hogi usko insert kar day ga similarly agay bhi
void Save_Game(char board[3][3]) { int i; FILE *savegame = fopen("save.bin", "w"); for (i = 0; i < 3; i++) { fprintf(savegame, "%c %c %c\n", board[i][0], board[i][1], board[i][2]); } fclose(savegame); cout << "game saved"; }
int win() { if (table[1] == table[2] && table[2] == table[3]) return 1; else if (table[4] == table[5] && table[5] == table[6]) return 1;
//////////
解决方案
这篇关于Tic tac toe功能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!