sorry its quite big please help.
please try compile and then debug. the problem is with the rand_mines() function i think, and i cannot print the 2d array because i get this warning.pointer to integer without cast, please help me in need it fast. i am a newbie....
Code:
#include<stdio.h> // interger to pointer without cast PROBLEM....
#include<stdlib.h>
void welcome();
void rand_mines(int msweep[12][12]);
void printmatrix(int a[11][11],int r);
int process(int msweep[12][12],int r,int c);
int main()
{
int msweep[12][12] = {{0}};
int i,r,c;
welcome();
rand_mines(msweep);
// printmatrix(msweep,11); // note grid from 1 to 11
printf("Enter you location on the minefield x,y\n");
scanf("%d%d",&r,&c);
i = process(msweep,r,c);
while(i)
{
printf("Lucky BRAT, live on for another step\n");
printf("enter next move ... ");
scanf("%d%d",&r,&c);
i = process(msweep,r,c);
printf(" %d Surrounding MINEs\n",msweep[r][c]);
}
if(i=0)
printf("Game OVER, ta ta. you stepped on a MINE !!\n");
return 0;
}
void welcome()
{
char op;
printf("Welcome to MINESWEEPER in C >>.....\n");
printf("Enter <<\n");
printf(" i for instructions\n");
printf(" e to enter game\n");
scanf("%c",&op);
if(op == 'i')
{
printf("OH DEAR, what a shock you are unfortunatly in the midst of a "); printf("mine field.\n");
printf("Enter the coordinates of the x and y plane between 0 to 9\n");
printf("Are you destined to DIE or live ?\n");
printf("HA ha ha huh, GOOD LUCK\n");
}
else
return;
}
void rand_mines(int msweep[12][12])
{
int r,c,m;
//srand(12);
for(m=0;m<20;m++)
{
r = rand() % 11;
if(r = 0)
r = 10;
c = rand() % 11;
if(c == 0)
c = 2;
msweep[r][c] = 9;
printf("%d %d \n",r,c);
}
return;
}
void printmatrix(int a[][11],int r)
{
int i,j;
for(i=1;i<r;i++)
{
for(j=1;j<11;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
return;
}
int process(int msweep[12][12],int r,int c)
{
int i,j,b=0;
if(msweep[r][c] == 9)
return 0;
else
{
if(msweep[i-1][j-1] == 9)
b++;
if(msweep[i-1][j] == 9)
b++;
if(msweep[i-1][j+1] == 9)
b++;
if(msweep[i][j-1] == 9)
b++;
if(msweep[i][j+1] == 9)
b++;
if(msweep[i+1][j-1] == 9)
b++;
if(msweep[i+1][j] == 9)
b++;
if(msweep[i+1][j+1] == 9)
b++;
msweep[r][c] = b;
}
return 1;
}

