parsing_input v0 (Not working yet)
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
|
||||
/* Updated: 2019/04/15 20:19:55 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/15 20:49:33 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -127,13 +127,13 @@ int add_to_list(char **square, t_fillist **list)
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
static t_fillist *list = NULL; // avant d'appeller add_to_list il faut declarer un pointeur static vers la structure
|
||||
int i;
|
||||
|
||||
if (ac > 4)
|
||||
if (ac > 1)
|
||||
{
|
||||
add_to_list(++av, &list); // l'appel de la fonction se fait avec un carre valide de 4*4 et l'adresse du pointeur vers la liste
|
||||
if (ac == 9)
|
||||
@@ -149,3 +149,4 @@ int main(int ac, char **av)
|
||||
|
||||
return (0);
|
||||
}
|
||||
*/
|
||||
|
||||
29
fillit.h
29
fillit.h
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/15 16:23:18 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/04/15 20:53:57 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,22 +22,6 @@
|
||||
|
||||
# define BUFF_SIZE 1024
|
||||
|
||||
/*
|
||||
** DELETE BEFORE EVALUATION
|
||||
*/
|
||||
|
||||
void print_test(char *test);
|
||||
|
||||
/*
|
||||
** FUNCTIONS
|
||||
*/
|
||||
|
||||
char *read_file(char *file);
|
||||
void print_error(char *s);
|
||||
int check_file_errors(char *file);
|
||||
int check_tetri_errors(char *tetri);
|
||||
int check_tetri_errors2(char *tetri);
|
||||
|
||||
/*
|
||||
** STRUCTURE
|
||||
*/
|
||||
@@ -52,6 +36,17 @@ typedef struct s_fillist
|
||||
struct s_fillist *next;
|
||||
} t_fillist;
|
||||
|
||||
/*
|
||||
** FUNCTIONS
|
||||
*/
|
||||
|
||||
void print_test(char *test); //DELETE BEFORE EVALUATION
|
||||
char *read_file(char *file);
|
||||
void print_error(char *s);
|
||||
void parse_input(char *input);
|
||||
int check_file_errors(char *file);
|
||||
int check_tetri_errors(char *tetri);
|
||||
int check_tetri_errors2(char *tetri);
|
||||
int add_to_list(char **square, t_fillist **list);
|
||||
|
||||
#endif
|
||||
|
||||
5
main.c
5
main.c
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/15 14:41:44 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/15 20:54:24 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,13 +22,14 @@ int main(int argc, char **argv)
|
||||
print_error("Error: Could not read file.\n");
|
||||
if (check_file_errors(input))
|
||||
print_error("Error: Invalid file.\n");
|
||||
parse_input(input);
|
||||
/*
|
||||
Transform input to tetriminos
|
||||
Backtracking for smallest square
|
||||
Transform tetriminos with letters
|
||||
Print result
|
||||
*/
|
||||
print_test(input);
|
||||
//print_test(input);
|
||||
}
|
||||
else
|
||||
print_error("Usage: Please submit a file.\n");
|
||||
|
||||
@@ -6,30 +6,61 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/15 20:14:43 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/15 21:33:52 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fillit.h"
|
||||
|
||||
/*
|
||||
** Function that parse a file and return each tetrimino
|
||||
** Function that parse a file and put each tetrimino in a linked list
|
||||
*/
|
||||
/*
|
||||
|
||||
void parse_input(char *input)
|
||||
{
|
||||
char *tetri;
|
||||
int i;
|
||||
//static t_fillist *list = NULL;
|
||||
char **square;
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
|
||||
i = 0;
|
||||
while (input[i])
|
||||
{
|
||||
tetri[i] = input[i];
|
||||
if (i != 0 && i%19 == 0)
|
||||
j = 0;
|
||||
while (j < 4)
|
||||
{
|
||||
|
||||
i+2;
|
||||
k = 0;
|
||||
while (k < 4)
|
||||
square[j][k++] = input[i++];
|
||||
j++;
|
||||
}
|
||||
printf("print:\n%s\n", *square);
|
||||
//add_to_list(square, &list);
|
||||
while (input[i] == '\n')
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void parse_input(char *input)
|
||||
{
|
||||
//static t_fillist *list = NULL;
|
||||
char square[19];
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = 0;
|
||||
while (input[i])
|
||||
{
|
||||
j = 0;
|
||||
while (j < 19)
|
||||
square[j++] = input[i++];
|
||||
square[19] = '\0';
|
||||
printf("PRINT:\n%s\n", square);
|
||||
//add_to_list(square, &list);
|
||||
while (input[i] == '\n')
|
||||
i++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user