Deciphering code...

I've copied a tutorial for a minesweeper game and I really want to understand what is happening in it, I can't understand hardly any of it, like how the mines are placed and what certain functions are doing so I can learn more.

here is the code https://pastebin.com/0ArLHDkq
... like how the mines are placed
1
2
3
4
5
6
7
8
9
10
11
12
13
//Placing mines
void mines(int a[][8], int size) {
    for (int i = 0; i<10; i++)
    {
        int row = rand() % size;
        int col = rand() % size;
        if (a[row][col] == 9)
        {
            i--;
        }
        a[row][col] = 9;
    }
}

The grid appears to be a square of size size x size.
The function mines() places 10 mines at random positions. The positions are the row, col assignments. Placing mine means setting 9 in that position.
Topic archived. No new replies allowed.