typedef struct scubfile tcubfile; struct s_cubfile { char *no_path; //juste une char…
- User
typedef struct s_cubfile t_cubfile; struct s_cubfile { char *no_path; //juste une char contenant le path char *so_path; char *we_path; char *ea_path; int *floor_color; //exemple de ce que sa peux contenire: 220,100,0 int *ceiling_color; int row_length; //la c est la longueur d une rangee de la map int column_length; //la c est la longueur d une colone de la map int **map; int *player_coor; //vue que la map est en int, je peux pas mettre de player dedans. du coup ici c est la ou on vas savoir les coordonne du player. les coordonné dans la map commence a 0,0 char player_orientation; //juste un caractere minuscule n, s, e ou w }; peux tu me faire un code en C pour inicialiser cette structure
- Assistant
- User
int main(void) { int co = 0; int fd;
//stuff to verify int number_of_path = 0; char *line; t_cubfile *my_cubfile; fd = open("map.cub", O_RDONLY); while (co <= 50) { line = get_next_line(fd); if (!line) { if (number_of_path < 4) printf("not enouth paths\n"); if (number_of_path > 4) printf("too much paths\n"); printf("no more lines\n"); return(0); } if (line[0] == 'N' && line[1] == 'O' && line[2] == ' ') { number_of_path++; printf("it s the north path\n"); line[strlen(line) - 1] = '\0'; if (test_existence(&line[3]) == 1) { printf("file invalid\n"); return (0); } my_cubfile->no_path = ft_strdup(&line[3]); } else if (line[0] == 'S' && line[1] == 'O' && line[2] == ' ') { ┌──(overlord㉿Overlord)-[~/Bureau/cub3dverif/fini]└─$ ./a.out
it s the north path zsh: segmentation fault ./a.out┌──(overlord㉿Overlord)-[~/Bureau/cub3dverif/fini] └─$
- Assistant