Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 我在使用多维数组编译方法时遇到问题_C - Fatal编程技术网

C 我在使用多维数组编译方法时遇到问题

C 我在使用多维数组编译方法时遇到问题,c,C,我需要显示一个具有此结构的板 仅使用O-|字符 有这个错误吗 main.c:17:29:错误:在']'标记之前应该有主表达式 desplegar_tablero(&tablero[][],菲律宾,哥伦比亚) (仍然没有完成算法,但我正在进行) int main(int argc,char**argv){ 如果(argc!=3){ fprintf(标准,“Ejecutar como./prog N_filas N_columns.\N”); 退出(退出失败); } int fil=2*(atoi

我需要显示一个具有此结构的板

仅使用O-|字符

有这个错误吗

main.c:17:29:错误:在']'标记之前应该有主表达式 desplegar_tablero(&tablero[][],菲律宾,哥伦比亚)

(仍然没有完成算法,但我正在进行)

int main(int argc,char**argv){
如果(argc!=3){
fprintf(标准,“Ejecutar como./prog N_filas N_columns.\N”);
退出(退出失败);
}
int fil=2*(atoi(argv[1])-1;
int col=2*(atoi(argv[2])-1;
字符表[fil][col];
desplegar_tablero(&tablero[][],菲律宾,哥伦比亚);
}
无效数据表(字符表[],整数f,整数c){

对于(int i=1;i
&tablero[][]
->
tablero
char tab[][]
->不完整的元素类型。声明数组参数时,必须声明要完成类型的列数,例如
char tab[][10]
。您可以将指针传递到指针,而无需声明恒定的列宽。
void desplegar_tablero(char tab[],int f,int c){
-->
void desplegar_tablero(int f,int c,char tab[f][c]){
,call desplegar_tablero(fil,col,tablero);
printf(“%u”,“and tab i][j]);
-->
printf(“%c”,tab[i][j]);
用于(int i=1;i
int main(int argc, char **argv){
    if (argc != 3){
        fprintf(stderr, "Ejecutar como ./prog N_filas N_columnas.\n");
        exit(EXIT_FAILURE);
    }

    int fil = 2*(atoi(argv[1]))-1;
    int col = 2*(atoi(argv[2]))-1;

    char tablero[fil][col];

    desplegar_tablero(&tablero[][],fil,col);


}

void desplegar_tablero(char tab[][], int f, int c){
    for (int i = 1; i<= f; ++f){
        for (int j = 1; j <=c; ++c){
            //Si fila es impar 
            if (i%2 == 1){
                //Columna Impar
                if (j%2 == 1){
                    // ASCII 79 = O
                    tab[i][j]= 79;
                    printf(" %u ",&tab[i][j]);
                }   
                //Columna par   
                else{
                    // ASCII 196 = -
                    tab[i][j] = 196;
                    printf(" %u ",&tab[i][j]);
                }   
            }
            // Si fila par
            else{
                //Columna impar 
                if (j%2==1){
                    // ASCII 179 = |
                    tab[i][j]= 179;
                    printf(" %u ",&tab[i][j]);
                }
                //Columna par   
                else{
                    // ASCII 32 = espacio
                    tab[i][j] = 32;
                    printf(" %u ",&tab[i][j]);
                }
            }
        printf("\n");   
        }
    }
}