The name of the method you're looking for is called 'serialization'. Whether it is output to a text file or a binary file doesn't matter. What matters is that you store the data necessary to recreate a game state and that you read it back the same way you save it.
In Allegro 5, you can use the https://liballeg.org/a5docs/trunk/file.html (FILE I/O) routines to save your text or to save binary data.
As for your specific situation, you have a board (a 2D array) of stone types (an enum).
The value of a position on the board can be in one of 3 different states ; 1) empty 2)black 3)white.
So first, make an enum for your data :
enum PIECE {
NONE = 0,
WHITE = 1,
BLACK = 2
};
const char[3] piecetypes = {'-' , 'O' , 'X'};
In GO, there are usually 19x19 pieces.
In serializing data like an array, we need to record its size somewhere.
First job is to open a file. Typical usage is of http://www.cplusplus.com/reference/cstdio/fopen/ fopen, or in Allegro 5, https://liballeg.org/a5docs/trunk/file.html#al_fopen al_fopen.
Once the file is open for writing (make sure to specify whether you're writing in text or binary mode!!!), write the board to the file.
Since we're using an enum with less than 8 values, and there aren't that many values (19x19 = 361), we'll represent our data in the file with a char (a single byte).
ALLEGRO_FILE* f = al_fopen("go.sav" , "w");/// Opening in text mode for writing
if (!f) {Bail();}
for (unsigned int y = 0 ; y < 19 ; ++y) {
for (unsigned int x = 0 ; x < 19 ; ++x) {
al_fputc(piecetypes[board[y][x]]);
}
al_fputc('\n');
}
al_fputc('\n');
al_fclose(f);
/// All done
Now our data should be saved something like this (open the text file in your favorite editor and verify the contents) :
-------------------
-------------------
-------------------
-------------------
-------------------
-----XX------------
------O------------
---------O---------
---------XX--------
----------OO-------
---------O---------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
-------------------
Now you need to be able to 'unserialize' the data, that is to say, to read it back from the file.
Open the file for reading and copy the data back into your board :
ALLEGRO_FILE* f = al_fopen("go.sav" , "r");
if (!f) {Bail();}
for (unsigned int y = 0 ; y < 19 ; ++y) {
for (unsigned int x = 0 ; x < 19 ; ++x) {
char c = al_fgetc(f);
if (c == '-') {board[y][x] = NONE;continue;}
board[y][x] = (c == 'O')?WHITE:BLACK;
}
al_fgetc(f);/// consume the newline
}
al_fclose(f);