First version with working test (read and print file)
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/12 22:29:45 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:30:32 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:02:22 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
char *get_smallest_square(/*args*/)
|
||||
{
|
||||
/*backtracking*/
|
||||
|
||||
@@ -6,16 +6,20 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:27:28 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:06:40 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
void ft_display_error(char *s, int fd)
|
||||
{
|
||||
write(fd, s, strlen(s));
|
||||
}
|
||||
|
||||
int ft_tetri_erros(/*args*/)
|
||||
/*
|
||||
int ft_tetri_erros()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:27:42 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:13:42 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *input;
|
||||
@@ -19,8 +21,8 @@ int main(int argc, char **argv)
|
||||
{
|
||||
if (!(input = read_file(argv[1])))
|
||||
ft_display_error("Error: Could not read file.\n", 2);
|
||||
else if (/*Elements in file not valid*/)
|
||||
ft_display_error("Error: Invalid file.\n", 2);
|
||||
// else if (/*Elements in file not valid*/)
|
||||
// ft_display_error("Error: Invalid file.\n", 2);
|
||||
/*
|
||||
Transform input to tetriminos
|
||||
Check if every tetrimino is valid
|
||||
@@ -28,6 +30,7 @@ int main(int argc, char **argv)
|
||||
Transform tetriminos with letters
|
||||
Print result
|
||||
*/
|
||||
print_test(input);
|
||||
}
|
||||
else
|
||||
ft_display_error("Error: Please submit a file.\n", 2);
|
||||
|
||||
@@ -6,11 +6,20 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:35:48 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:26:27 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:13:16 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
void ft_print_fillit(/*args*/)
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
/*
|
||||
void ft_print_fillit()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void print_test(char *test)
|
||||
{
|
||||
write(1, test, strlen(test));
|
||||
}
|
||||
|
||||
36
srcs/read_file.c
Normal file
36
srcs/read_file.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* read_file.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/13 12:09:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/14 12:08:12 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
char *read_file(char *file)
|
||||
{
|
||||
char buf[BUFFER_SIZE];
|
||||
int fd;
|
||||
int rv;
|
||||
int i;
|
||||
char *result;
|
||||
|
||||
if (((fd = open(file, O_RDONLY)) < 0) \
|
||||
|| ((rv = read(fd, &buf, BUFFER_SIZE)) < 0) \
|
||||
|| !(result = malloc(sizeof(char))))
|
||||
return (NULL);
|
||||
buf[rv] = '\0';
|
||||
i = 0;
|
||||
while (rv--)
|
||||
{
|
||||
result[i] = buf[i];
|
||||
i++;
|
||||
}
|
||||
close(fd);
|
||||
return (result);
|
||||
}
|
||||
@@ -6,11 +6,13 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/12 22:31:30 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/04/12 22:31:51 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/04/14 12:08:58 by vmanzoni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *tetri_to_letters(/*args*/)
|
||||
#include "../includes/fillit.h"
|
||||
|
||||
char *tetri_to_letters()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user