Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement