With putting the random number generator I had linking errors due to code from card.c calling myRandom. So I just kept the way I had before. Still trying to find a way so I can call a random number, mark it on the board, then call the next numbers.
Code:
// Bingo main.c
#include <stdio.h>
#include "globals.h"
#include "card.h"
#include "randomnumber.h"
#include "unusednumbers.h"
#include "blockChars.h"
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#define TRUE 1
#define FALSE 0
char finitial, linitial, Player1;
int main()
{
initRandom();
/* srand (time (NULL) );
int MyRandom(int low, int high)
{
return (rand() % (high - low)) + low;
} */
int iseed, j, randomn, low, high;
printf(" Welcome to the game of Bingo\n");
printf("Enter your initials\n");
scanf(" %c %c", &finitial, &linitial);
newCard();
Displaycard();
randomn = myRandom(low, high);
printf(" Calling first number :%d\n", randomn);
// printCell (bingoCard[i][j]);
/*while (i < 25)
{
srand (time (NULL) );
iseed = rand() % 75 + 1;
printf( "Calling first number :%d\n", iseed);
if(bingoCard[i][j] == iseed)
{
printf(" ** ");
i = i +1;
}
if(bingoCard[i][j] != iseed)
{
printf(" The number %d is not on the board\n", iseed);
i = i +1;
*/
printf(" Thank you for joining us %c%c\n", finitial, linitial);
system("Pause");
}
Code:
//card.c
#include<stdio.h>
#define MARKED_VAL 0
int bingoCard[NUMROWS][NUMCOLS];
void newCard(void)
{
int nchoice = MULT;
int row, col;
int min, max;
for (col = 0; col < NUMCOLS; col++)
{
min = (col * nchoice) + 1;
max = (col + 1) * nchoice;
for (row = 0; row < NUMROWS; row++)
{
bingoCard[row][col] = myRandom(min, max);
}
}
bingoCard[(row / 2)] [(col / 2)] = MARKED_VAL;
}
void printCell(int cellValue)
{
printf("|");
if (cellValue == MARKED_VAL)
{
printf(" ** ");
}
else
{
printf(" %2d ", cellValue);
}
}
void Displaycard(void)
{
int i, j;
printf("\n Bingo Card for Player 1\n\n");
printf("+------+------+------+------+------+\n");
printf("| B | I | N | G | O |\n");
printf("+------+------+------+------+------+\n");
for (i = 0; i < NUMROWS; i++)
{
for (j = 0; j < NUMCOLS; j++)
{
printCell (bingoCard[i][j]);
}
printf("|\n+------+------+------+-------+------+\n");
}
}
int updateCell(void)
{
}
int checkforWin()
{
}
int checkRows()
{
int i, j;
for ( i = 0; i < 5; i++)
for( j = 0; j < 5; j++)
if (bingoCard[i][0] == bingoCard[i][j])
return 1;
}
int checkColums()
{
int i, j;
for( i = 0; i < 5; i++)
for ( j = 0; j < 5; j++)
if (bingoCard[0][j] == bingoCard[i][j])
return 1;
}
int checkDiagnols()
{
int i;
for( i = 0; i < 5; i++)
if (bingoCard[0][0] == bingoCard[i][i])
return 1;
}