-
-
Save Tomcat-42/343c37787c7d0d80575dcf04fa3da525 to your computer and use it in GitHub Desktop.
n funciona direito
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void scanLab(Labirinto *l, int m, int n) | |
{ | |
int i; | |
/*possível ocorrência da entrada ou saída em alguma linha*/ | |
char *ocu_in, *ocu_out; | |
char *tmp = (char *)malloc((n+1) * sizeof(char)); | |
l->m = m; | |
l->n = n; | |
/*Aloca o array de ponteiros para arrays de caractres*/ | |
l->matriz = (char **)malloc(m*sizeof(char)); | |
/*Aloca e lê as linhas individuais*/ | |
for(i=0; i<m; i++) | |
{ | |
*(l->matriz+i) = (char *)malloc((n+1)*sizeof(char)); | |
scanf("%s", tmp); | |
ocu_in = strchr(tmp, 'e'); | |
ocu_out = strchr(tmp, 's'); | |
/*Encontrou entrada ou saída*/ | |
if(ocu_in) | |
{ | |
l->in.i = i; | |
l->in.j = ocu_in - tmp; | |
ocu_in = NULL; | |
} | |
else if(ocu_out) | |
{ | |
l->out.i = i; | |
l->out.j = ocu_out - tmp; | |
ocu_out = NULL; | |
} | |
strcpy(*(l->matriz+i), tmp); | |
} | |
free(tmp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment