/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parser.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: kjimenez +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/24 14:28:23 by kjimenez #+# #+# */ /* Updated: 2022/07/24 14:28:26 by kjimenez ### ########.fr */ /* */ /* ************************************************************************** */ #include int check_input(char *str) { int i; i = -1; while (str[++i]) { if (i % 2 == 1) { if (str[i] != ' ') return (0); } else if (i % 2 == 0) { if (str[i] < '1' || str[i] > '4') return (0); } } if (i != 31) return (0); return (1); } int **str_to_tab(char *str) { int i; int j; int k; int **check; i = -1; check = (int **) malloc(4 * sizeof(int *)); while (++i < 4) check[i] = (int *) malloc(4 * sizeof(int)); i = -1; k = 0; while (++i < 4) { j = -1; while (++j < 4) { check[i][j] = str[k] - '0'; k += 2; } } return (check); }