For my project I had to make a game in c++. Our teacher picked a board game called Squadro. To explain quickly we have a board with 49 boxes and 10 pawns, 5 red and 5 yellow. And at each turn, players have to move their pawn etc.
At the beginning the game looks like this :
If you want more informations about this game follow this link : https://www.youtube.com/watch?v=pzOK7b_sq2I (it's in french, but nevertheless I think you will understand). But the problem is not here. I've made a GUI with SFML and so on. We have to implement one more functionnality. Indeed we must let users saving their game or not. I managed to do it by writing in a text file the date, name of players and a "matrix" of the game. And here is my problem : lauching a game. I think it's maybe not so hard but I tried so many ideas. So what do I need to resolve my problem ? I have to open my text file called "saves.txt" (already done) and to get the useful data : Get the date of the game, names of players and build my matrix and finally I can lauch the game. To help me in this task I share with you what I've already done and what my saves.txt looks like.
Thanks for help !
currently my saves.txt looks like :
my code to save a game :
else if(event.key.code == sf::Keyboard::Escape) //if the user press escape it will close the SFML Window
        {
            window.close();
            system("cls");
            cout << "Wanna save the game? " << endl;
            string choice;
            cin >> choice;
            if((choice == "yes") || (choice == "Yes") || (choice == "YES"))
                    {
                        //Get date and current time
                        time_t tt;
                        struct tm * ti;
                        time (&tt);
                        ti = localtime(&tt);
                        cout << asctime(ti) << endl;
                        //Opening the file
                        string const File("saves.txt");
                        ofstream Flux(File.c_str(), ios::app);
                        Flux << "----------------------------------------------------" << endl;
                        Flux << "date  " << asctime(ti)  << endl;
                        Flux << "Type of game : two players" << endl;
                        Flux << "currentPlayer : " << currentPlayer << endl;
                        Flux << "waitingPlayer : " << waitingPlayer << endl;
                        cout << endl;
                        if(Flux)
                        {
                            for(int u=0; u < 7; u++)
                            {
                                for(int v=0; v < 7; v++)
                                {
                                    if(game[u][v] != ' ')
                                    {
                                        Flux << game[u][v] << " line : " << u << " | column :" << v << endl;
                                    }
                                }
                                cout << endl;
                            }
                            Flux << "\n----------------------------------------------------" << endl;
                        }
                        else
                        {
                            cerr << "ERROR : Impossible to save the game ! " << endl;
                        }
                    }
                    else
                    {
                        exit(0);
                    }
and my unfinished function loadGame();
void loadGame()
{
vector<string> dateGame(5);
ifstream file;
file.open("saves.txt");
if(file.fail())
{
    cerr << "Error at the opening of the file";
    exit(1);
}
string search = "date";
bool isFound = 0;
while(!file.eof())
{
    string temp = "";
    getline(file,temp);
    for(int i = 0; i < search.size(); i++)
    {
      if(temp[i]==search[i])
      {
            isFound = 1;
            dateGame.push_back(search[i]); //it doesn't work
      }
        else
        {
            isFound =0;
            break;
        }
    }
    if(isFound)
    {
        cout << "Password is: ";
        for(int i = search.size()+1;i<temp.size();i++)
            cout << temp[i];
        break;
    }
}
if(file.eof()&&(!isFound))
{
    cout << "String not found!\n";
}
file.close();
}
and after getting my data I'll be able to lauch init(char game[7][7], ... , **params);
EDIT : my game is represented like this :
 char game[7][7] = {
                    {' ',' ',' ',' ',' ',' ',' '},
                    {'>',' ',' ',' ',' ',' ',' '},
                    {'>',' ',' ',' ',' ',' ',' '},
                    {'>',' ',' ',' ',' ',' ',' '},
                    {'>',' ',' ',' ',' ',' ',' '},
                    {'>',' ',' ',' ',' ',' ',' '},
                    {' ','A','A','A','A','A',' '}
                };
 
    