char *ft_strtrim(char const *s) { char *str; char *str_start; int size; int i; int j; j = 0; i = 0; str_start = del_space((char *)s); size = ft_strlen(str_start); str = ft_strnew(ft_strlen(s)); if (size == 0) return (str); size--; while (size - j >= 0 && (str_start[size - j] == ' ' || str_start[size - j] == '\t' || str_start[size - j] == '\n')) j++; while (i < size - j + 1) { str[i] = str_start[i]; i++; } str[i] = '\0'; return (str); }
int check_room(char *str) { int i; int nb_a; char *tmp; if (!str) return (0); tmp = del_space(str); nb_a = nb_args(tmp); if (nb_a != 3 || tmp[0] == '#') { free(tmp); return (0); } else i = check_room2(tmp); if (!tmp[i]) { free(tmp); return (1); } free(tmp); return (0); }