I see. Here's a quick rewrite of your program with local variables and (perhaps) somewhat better variable names and better spacing. I decided to interpret your 3rd parameter as the number of mines for now (you can change that).
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ROWS 40
#define MAX_COLS 40
void play(int cols, int rows, int num_mines);
int main (int argc, char * argv[]) {
int cols, rows, num_mines;
if (argc != 4) {
printf("Invalid parameters.\n");
return 1;
} else {
cols = atoi(argv[1]);
rows = atoi(argv[2]);
// You should check that cols and rows are not out-of-range.
num_mines = atoi(argv[3]);
}
play(cols, rows, num_mines);
return 0;
}
void play(int cols, int rows, int num_mines) {
char game[MAX_ROWS][MAX_COLS];
int x, y, i;
memset(game, '.', MAX_ROW * MAX_COL);
for (i = 0; i < num_mines; i++) {
do {
x = rand() % cols;
y = rand() % rows;
} while (game[y][x] == '*');
game[y][x] = '*';
}
printf(" ");
for (x = 0; x < cols; x++) {
printf(" %2d", x);
}
for (y = 0; y < rows; y++) {
printf("\n%2d", y);
for (x = 0; x < cols; x++) {
printf(" %c", game[y][x]);
}
printf("\n");
}
}