good.
I have a labyrinth like this:
*************
* F*
* **** * * *
* ** * * *
* ** *** * *
*S *
*************
And I would like to print it in the program by means of loops, but I am getting a problem which is the following:
laberinto.c:30:39: error: invalid initializer
char laberinto[ANCHURA][ALTURA]=getc(f);
The code that is being used is the following:
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#define ALTURA (7)
#define ANCHURA (13)
void imprimirLaberinto(char laberinto[ANCHURA][ALTURA]){
int i;
int j;
for (i = 0; i < ANCHURA; i++) {
for (j = 0; j < ALTURA; j++) {
printf("%c ", laberinto[i][j]);
}
putchar('\n');
}
}
int main(int argc, char *argv[]) {
int i;
int j;
FILE *f; //define que variable va a ser el archivo
f=fopen(argv[1],"r"); // Se selecciona el archivo y su modo (lectura, escritura, etc.)
char laberinto[ANCHURA][ALTURA]=getc(f);
if( f==NULL ){
printf("Error al abrir el laberinto\n"); // Condicional que checa si el archivo e*iste
}
else
{
imprimirLaberinto(laberinto);
}
}
I hope you can help me, thank you.