我正在嘗試在 c 中構建井字游戲。我必須要求用戶選擇尺寸(3 * 3 / 4 * 4 / ..)問題是它一直告訴我有問題..這是我的代碼:
#include <stdio.h>
#include <stdlib.h>
void printBoard(char** board, int size)
{
int i,j;
printf("\n");
for(i=0;i<size;i )
{
for(j=0;j<size;j )
{
printf("[%c] ",board[i][j]);
}
printf("\n");
}
}
int main()
{
int i,j,size;
printf("Enter the dimensions of the board: ");
scanf("%d %d",&i,&j);
if (i != j)
{
printf("Input error!");
return 0;
}
if (i == j)
{
char **board;
board = malloc(i*sizeof(char*));
for(int c=0; c < i; c )
{
board[c] = malloc(c*sizeof(char));
}
size = i = j;
printBoard(char **board,int size); /// Expected expression - what's wrong?
}
}
uj5u.com熱心網友回復:
-- printBoard(char **board,int size); /// Expected expression - what's wrong?
printBoard(board,size); /// Fixed
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/470628.html