mardi 28 mai 2019

i have a problem with a function using random

am working on a project of minesweeper but the problem is when i use this code to fill the array but when i use it it gives me error on the line of checking (if)

i've been trying to fix it for a while but for some reason it is not working

   int i, random,random2;
 srand(time(NULL));
        for (i = 0; i < minenum; i++)
    {
        random = rand() % (size);
                printf(" %d \n",random);
        random2=rand()%(size);
                printf(" %d \n",random2);
        if(board[random][random2]=='X') i--;
        printf("qwewqewqe");
        board[(int)random][(int)random2] = 'X';
                printf("%d \n",i);

    }
}

i expect it working without crashing!




Aucun commentaire:

Enregistrer un commentaire