aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--0-0-inter/examples.txt9
-rw-r--r--0-0-inter/subject.en.txt23
-rwxr-xr-x0-0-inter/subject.es.txt23
-rw-r--r--0-0-inter/subject.fr.txt23
-rw-r--r--0-0-inter/subject.ja.txt20
-rw-r--r--0-0-inter/subject.ko.txt26
-rwxr-xr-x0-0-inter/subject.pt.txt23
-rw-r--r--1-0-ft_printf/subject.en.txt33
-rw-r--r--1-0-ft_printf/subject.es.txt29
-rw-r--r--1-0-ft_printf/subject.fr.txt32
-rw-r--r--ft_printf/ft_printf.c176
-rw-r--r--ft_printf/main.c11
-rw-r--r--get_next_line/get_next_line.c7
-rw-r--r--get_next_line/main.c23
-rwxr-xr-xrendu/__GIT_HISTORY17
-rwxr-xr-xrendu/ft_printf/ft_printf.c302
-rwxr-xr-xrendu/inter/inter.c60
17 files changed, 620 insertions, 217 deletions
diff --git a/0-0-inter/examples.txt b/0-0-inter/examples.txt
new file mode 100644
index 0000000..57c63e8
--- /dev/null
+++ b/0-0-inter/examples.txt
@@ -0,0 +1,9 @@
+$>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
+padinto$
+$>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
+df6ewg4$
+$>./inter "rien" "cette phrase ne cache rien" | cat -e
+rien$
+$>./inter | cat -e
+$
+
diff --git a/0-0-inter/subject.en.txt b/0-0-inter/subject.en.txt
new file mode 100644
index 0000000..7259b8b
--- /dev/null
+++ b/0-0-inter/subject.en.txt
@@ -0,0 +1,23 @@
+Assignment name : inter
+Expected files : inter.c
+Allowed functions: write
+--------------------------------------------------------------------------------
+
+Write a program that takes two strings and displays, without doubles, the
+characters that appear in both strings, in the order they appear in the first
+one.
+
+The display will be followed by a \n.
+
+If the number of arguments is not 2, the program displays \n.
+
+Examples:
+
+$>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
+padinto$
+$>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
+df6ewg4$
+$>./inter "nothing" "This sentence hides nothing" | cat -e
+nothig$
+$>./inter | cat -e
+$
diff --git a/0-0-inter/subject.es.txt b/0-0-inter/subject.es.txt
new file mode 100755
index 0000000..0973b82
--- /dev/null
+++ b/0-0-inter/subject.es.txt
@@ -0,0 +1,23 @@
+Assignment name : inter
+Expected files : inter.c
+Allowed functions: write
+--------------------------------------------------------------------------------
+
+Escriba un programa que reciba como parámetros dos cadenas de caracteres y que
+muestre, sin duplicados, los caracteres comunes a las dos cadenas.
+
+Se mostrarán en el orden de aparición dentro de la primera cadena.
+La visualización se debe terminar con un salto de línea.
+
+Si el número de parámetros transmitidos es distinto de 2, el programa mostrará
+'\n'.
+
+Ejemplos:
+$>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
+padinto$
+$>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
+df6ewg4$
+$>./inter "algo" "no crea que esta frase esconde algo" | cat -e
+algo$
+$>./inter | cat -e
+$
diff --git a/0-0-inter/subject.fr.txt b/0-0-inter/subject.fr.txt
new file mode 100644
index 0000000..69cfee8
--- /dev/null
+++ b/0-0-inter/subject.fr.txt
@@ -0,0 +1,23 @@
+Assignment name : inter
+Expected files : inter.c
+Allowed functions: write
+--------------------------------------------------------------------------------
+
+Écrire un programme qui prend en paramètres deux chaînes de caractères et qui
+affiche sans doublon les caractères communs aux deux chaînes.
+
+L'affichage se fera dans l'ordre d'apparition dans la premiere chaîne.
+L'affichage doit être suivi d'un '\n'.
+
+Si le nombre de paramètres transmis est différent de 2, le programme affiche
+'\n'.
+
+Exemples:
+$>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
+padinto$
+$>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
+df6ewg4$
+$>./inter "rien" "cette phrase ne cache rien" | cat -e
+rien$
+$>./inter | cat -e
+$
diff --git a/0-0-inter/subject.ja.txt b/0-0-inter/subject.ja.txt
new file mode 100644
index 0000000..dca4ee8
--- /dev/null
+++ b/0-0-inter/subject.ja.txt
@@ -0,0 +1,20 @@
+課題名 : inter
+提出ファイル : inter.c
+使用可能な関数 : write
+--------------------------------------------------------------------------------
+
+2つの文字列をコマンドライン引数から受け取り、2つの文字列にあらわれる文字を最初の文字列にあらわれる順に
+標準出力に出力するプログラムを書きなさい。それと改行を標準出力に出力しなさい。
+
+もしコマンドライン引数の数が2つでは無い場合、改行だけを標準出力に出力する。
+
+例)
+
+$>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
+padinto$
+$>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
+df6ewg4$
+$>./inter "nothing" "This sentence hides nothing" | cat -e
+nothig$
+$>./inter | cat -e
+$
diff --git a/0-0-inter/subject.ko.txt b/0-0-inter/subject.ko.txt
new file mode 100644
index 0000000..e8e9961
--- /dev/null
+++ b/0-0-inter/subject.ko.txt
@@ -0,0 +1,26 @@
+Assignment name : inter
+Expected files : inter.c
+Allowed functions: write
+--------------------------------------------------------------------------------
+
+Write a program that takes two strings and displays, without doubles, the
+characters that appear in both strings, in the order they appear in the first
+one.
+두 문자열을 인자로 받아, 해당 두 문자열에 둘 다 나타나는 문자들을 화면에 중복 없이 출력하는 프로그램을 작성하시오. 이 때, 첫 번째 문자열에서 나타나는 순서대로 문자들을 출력합니다.
+
+The display will be followed by a \n.
+출력의 마지막에는 \n 이 따라와야 합니다.
+
+If the number of arguments is not 2, the program displays \n.
+만약 인자가 2개가 아닐 경우 \n 을 출력합니다.
+
+Examples:
+
+$>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
+padinto$
+$>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
+df6ewg4$
+$>./inter "nothing" "This sentence hides nothing" | cat -e
+nothig$
+$>./inter | cat -e
+$
diff --git a/0-0-inter/subject.pt.txt b/0-0-inter/subject.pt.txt
new file mode 100755
index 0000000..18e55b4
--- /dev/null
+++ b/0-0-inter/subject.pt.txt
@@ -0,0 +1,23 @@
+Assignment name : inter
+Expected files : inter.c
+Allowed functions: write
+--------------------------------------------------------------------------------
+
+Escreva um programa que tenha como parâmetro duas cadeias de caracteres e que
+mostre sem duplicações os caracteres comuns às duas cadeias.
+
+A exibição deve ser feita seguindo a ordem em que os caracteres aparecem na primeira cadeia.
+A exibição deve ser seguida de um '\n'.
+
+Se o número de parâmetros transmitidos for diferente de 2, o programa exibe
+'\n'.
+
+Exemplos:
+$>./inter "padinton" "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
+padinto$
+$>./inter ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
+df6ewg4$
+$>./inter "rien" "cette phrase ne cache rien" | cat -e
+rien$
+$>./inter | cat -e
+$
diff --git a/1-0-ft_printf/subject.en.txt b/1-0-ft_printf/subject.en.txt
new file mode 100644
index 0000000..f4a7861
--- /dev/null
+++ b/1-0-ft_printf/subject.en.txt
@@ -0,0 +1,33 @@
+Assignment name : ft_printf
+Expected files : ft_printf.c
+Allowed functions: malloc, free, write, va_start, va_arg, va_copy, va_end
+--------------------------------------------------------------------------------
+
+Write a function named `ft_printf` that will mimic the real printf with the following constraints:
+
+- It will manage only the following conversions: s,d and x
+- It will manage the minimum field width. (we will never test with a field with of 0)
+- It will manage only the precison flag `.`.
+
+Your function must be declared as follows:
+
+int ft_printf(const char *, ... );
+
+Before you start we advise you to read the `man 3 printf` and the `man va_arg`.
+To test your program compare your results with the true printf.
+
+Your function must not leak.
+
+
+Exemples of the function output:
+
+call: ft_printf("%10.2s\n", "toto");
+out: to$
+
+call: ft_printf("Magic %s is %5d", "number", 42);
+out:Magic number is 42%
+
+call: ft_printf("Hexadecimal for %d is %x\n", 42, 42);
+out:Hexadecimal for 42 is 2a$
+
+Warning: Your function must not have any leaks, this will be checked during moulinette \ No newline at end of file
diff --git a/1-0-ft_printf/subject.es.txt b/1-0-ft_printf/subject.es.txt
new file mode 100644
index 0000000..f1ee40d
--- /dev/null
+++ b/1-0-ft_printf/subject.es.txt
@@ -0,0 +1,29 @@
+Assignment name : ft_printf
+Expected files : ft_printf.c
+Allowed functions: malloc, free, write, va_start, va_arg, va_copy, va_end
+--------------------------------------------------------------------------------
+
+Escriba una función que se llame `ft_printf`, que reproducirá una pequeña parte del comportamiento del verdadero printf, con las siguientes limitaciones:
+
+
+- Sólo gestionará las conversiones : s,d y x
+- Debe gestionar el tamaño mínimo de campo. (Nunca probaremos su programa con un tamaño de campo igual a 0)
+- Sólo gestionará el flag de precisión `.`.
+
+La función deberá seguir el siguiente prototipo:
+
+int ft_printf(const char *, ... );
+
+Antes de empezar, le aconsejamos que lea `man 3 printf` y `man va_arg`.
+Le aconsejamos que para probar su programa lo compare con el verdadero printf.
+
+Ejemplos de salida de la función:
+
+call: ft_printf("%10.2s\n", "toto");
+out: to$
+
+call: ft_printf("Magic %s is %5d", "number", 42);
+out:Magic number is 42%
+
+call: ft_printf("Hexadecimal for %d is %x\n", 42, 42);
+out:Hexadecimal for 42 is 2a$
diff --git a/1-0-ft_printf/subject.fr.txt b/1-0-ft_printf/subject.fr.txt
new file mode 100644
index 0000000..852cd56
--- /dev/null
+++ b/1-0-ft_printf/subject.fr.txt
@@ -0,0 +1,32 @@
+Assignment name : ft_printf
+Expected files : ft_printf.c
+Allowed functions: malloc, free, write, va_start, va_arg, va_copy, va_end
+--------------------------------------------------------------------------------
+
+Vous devez rendre une fonction nommée `ft_printf` qui reproduira une petite partie du comportement du vrai printf avec les contraintes suivantes :
+
+- Vous devez gérer uniquement les conversions suivantes : s,d et x
+- Vous devez gérer la taille de champ minimal. (Nous ne testerons jamais votre programme avec une taille de champ minimal de 0)
+- Vous devez gérer uniquement le flag de précision `.`.
+
+Votre fonction devra être prototypée de la façon suivante :
+
+int ft_printf(const char *, ... );
+
+Avant de commencer nous vous conseillons la lecture du `man 3 printf` et du `man va_arg`.
+Nous vous recommandons de tester votre programme en le comparant avec le vrai printf.
+
+Votre fonction ne doit pas avoir de fuites mémoires.
+
+Exemples de sortie de la fonction:
+
+call: ft_printf("%10.2s\n", "toto");
+out: to$
+
+call: ft_printf("Magic %s is %5d", "number", 42);
+out:Magic number is 42%
+
+call: ft_printf("Hexadecimal for %d is %x\n", 42, 42);
+out:Hexadecimal for 42 is 2a$
+
+Rappel: Votre fonction ne doit pas avoir de fuites mémoire. Cela sera vérifié par la moulinette. \ No newline at end of file
diff --git a/ft_printf/ft_printf.c b/ft_printf/ft_printf.c
deleted file mode 100644
index d2abc40..0000000
--- a/ft_printf/ft_printf.c
+++ /dev/null
@@ -1,176 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-typedef struct
-{
- int precision;
- int width;
- char specifier;
-} t_format_spec;
-
-void ft_putchar(char c)
-{
- write(STDOUT_FILENO, &c, 1);
-}
-
-int ft_strlen(char *s)
-{
- int c;
-
- c = 0;
- while (s[c])
- c++;
- return (c);
-}
-
-void ft_putstr(char *s)
-{
- write(STDOUT_FILENO, s, ft_strlen(s));
-}
-
-int ft_isdigit(char c)
-{
- return (c >= '0' && c <= '9');
-}
-
-int ft_atoi_skip(char **s)
-{
- int nb;
- int is_neg;
-
- is_neg = **s == '-';
- nb = 0;
- while (ft_isdigit(**s))
- {
- nb *= 10;
- nb += **s - '0';
- (*s)++;
- }
- return (is_neg ? -nb : nb);
-}
-
-char *parse(char *format, t_format_spec *spec)
-{
- int tmp;
-
- if (ft_isdigit(*format))
- tmp = ft_atoi_skip(&format);
- if (*format == '.')
- {
- spec->precision = tmp;
- if (ft_isdigit(*++format))
- spec->width = ft_atoi_skip(&format);
- }
- else
- spec->width = tmp;
- if (*format != 's' && *format != 'd' && *format != 'x')
- return (NULL);
- spec->specifier = *format++;
- return (format);
-}
-
-int count_digits(int nb, int radix)
-{
- int counter;
-
- counter = nb < 0 ? 1 : 0;
- while (nb > 0)
- {
- nb /= radix;
- counter++;
- }
- return (counter);
-}
-
-char *ft_itoa_base(int nb, char *base)
-{
- int len;
- int radix;
- char *s;
-
- radix = ft_strlen(base);
- len = count_digits(nb, radix);
- if ((s = (char*)malloc(sizeof(char) * (len + 1))) == NULL)
- return (NULL);
- s[len] = 0;
- if (nb < 0)
- s[0] = '-';
- while (--len >= (nb < 0 ? 1 : 0))
- {
- s[len] = base[nb % radix];
- nb /= radix;
- }
- return (s);
-}
-
-int handle_s(va_list ap, t_format_spec *spec)
-{
- char *tmp;
-
- tmp = va_arg(ap, char*);
- ft_putstr(tmp);
- return (ft_strlen(tmp));
-}
-
-int handle_d(va_list ap, t_format_spec *spec)
-{
- int tmp;
- char *s;
-
- tmp = va_arg(ap, int);
- s = ft_itoa_base(tmp, "0123456789");
- ft_putstr(s);
- return ft_strlen(s);
-}
-
-int handle_x(va_list ap, t_format_spec *spec)
-{
- int tmp;
- char *s;
-
- tmp = va_arg(ap, int);
- s = ft_itoa_base(tmp, "0123456789abcdef");
- ft_putstr(s);
- return ft_strlen(s);
-}
-
-int print_spec(va_list ap, t_format_spec *spec)
-{
- if (spec->specifier == 's')
- return (handle_s(ap, spec));
- else if (spec->specifier == 'd')
- return (handle_d(ap, spec));
- else if (spec->specifier == 'x')
- return (handle_x(ap, spec));
- else
- return (-1);
-}
-
-int ft_printf(char *format, ...)
-{
- va_list ap;
- int counter;
- t_format_spec spec;
-
- va_start(ap, format);
-
-
- counter = 0;
- while (*format)
- {
- if (*format == '%')
- {
- if ((format = parse(format + 1, &spec)) == NULL)
- return (-1);
- counter += print_spec(ap, &spec);
- }
- else
- {
- ft_putchar(*format++);
- counter++;
- }
- }
- va_end(ap);
- return (counter);
-}
diff --git a/ft_printf/main.c b/ft_printf/main.c
deleted file mode 100644
index 57a3e33..0000000
--- a/ft_printf/main.c
+++ /dev/null
@@ -1,11 +0,0 @@
-int ft_printf(char *format, ...);
-
-int main(void)
-{
- ft_printf("bonjour\n");
- ft_printf("bon\n\0jour\n");
-
- ft_printf("s: %s\n", "yoyo");
- ft_printf("d: %d\n", 123);
- ft_printf("x: %x\n", 0xffee);
-}
diff --git a/get_next_line/get_next_line.c b/get_next_line/get_next_line.c
deleted file mode 100644
index 51df24c..0000000
--- a/get_next_line/get_next_line.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-
-int get_next_line(int fd, char **line)
-{
-
-}
diff --git a/get_next_line/main.c b/get_next_line/main.c
deleted file mode 100644
index b6595e0..0000000
--- a/get_next_line/main.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-int get_next_line(int fd, char **line);
-
-int main(int argc, char **argv)
-{
- int fd;
- char *line;
-
- fd = open(argv[1], O_RDONLY);
- for (int i = 0; get_next_line(fd, &line) == 1; i++)
- {
- printf("%d [%s]\n", i, line);
- free(line);
- }
- printf("$ [%s]\n", line);
- free(line);
-
- return 0;
-}
diff --git a/rendu/__GIT_HISTORY b/rendu/__GIT_HISTORY
new file mode 100755
index 0000000..db7e346
--- /dev/null
+++ b/rendu/__GIT_HISTORY
@@ -0,0 +1,17 @@
+commit 1b183fd8e61d1b681e6111dc04ab3bc168e191da
+Author: Exam 42 <exam-no-reply@42.fr>
+Date: Fri Feb 14 18:54:40 2020 +0100
+
+ bonjour
+
+ ft_printf/ft_printf.c | 302 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 302 insertions(+)
+
+commit d11e40fad81c20d5af3cb4ff4a716a783ee7ff61
+Author: Exam 42 <exam-no-reply@42.fr>
+Date: Fri Feb 14 17:16:09 2020 +0100
+
+ b
+
+ inter/inter.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 60 insertions(+)
diff --git a/rendu/ft_printf/ft_printf.c b/rendu/ft_printf/ft_printf.c
new file mode 100755
index 0000000..791efc3
--- /dev/null
+++ b/rendu/ft_printf/ft_printf.c
@@ -0,0 +1,302 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* utils.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: exam <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 16:57:09 by exam #+# #+# */
+/* Updated: 2020/02/14 18:54:02 by exam ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include <stdio.h>
+void ft_putchar(char c)
+{
+ write(1, &c, 1);
+}
+
+int ft_strlen(char *s)
+{
+ int i;
+
+ i = 0;
+ while (s[i])
+ i++;
+ return (i);
+}
+
+void ft_putstr(char *s)
+{
+ write(1, s, ft_strlen(s));
+}
+
+char *ft_strcpy(char *dest, char *src)
+{
+ char *s;
+
+ s = dest;
+ while (*src)
+ *dest++ = *src++;
+ *dest = '\0';
+ return (s);
+}
+
+char *ft_strdup(char *s)
+{
+ char *clone;
+
+ if ((clone = malloc(ft_strlen(s) + 1)) == NULL)
+ return (NULL);
+ ft_strcpy(clone, s);
+ return (clone);
+}
+
+char *ft_strcat(char *dest, char *src)
+{
+ char *s;
+
+ s = dest;
+ while (*dest)
+ dest++;
+ while (*src)
+ *dest++ = *src++;
+ *dest = '\0';
+ return (s);
+}
+
+static int st_itoa_base_count(long num, int radix)
+{
+ int counter;
+
+ counter = 0;
+ if (num <= 0)
+ counter = 1;
+ while (num > 0)
+ {
+ num /= radix;
+ counter++;
+ }
+ return (counter);
+}
+
+char *ft_itoa_base(long long num, char *base)
+{
+ int radix;
+ char *s;
+ int i;
+ int is_neg;
+
+ radix = ft_strlen(base);
+ if ((s = malloc(st_itoa_base_count(num, radix) + 1)) == NULL)
+ return (NULL);
+ s[st_itoa_base_count(num, radix)] = '\0';
+ is_neg = 0;
+ if (num < 0)
+ {
+ s[0] = '-';
+ num = -num;
+ is_neg = 1;
+ }
+ i = st_itoa_base_count(num, radix);
+ if (num == 0)
+ {
+ s[0] = base[0];
+ return (s);
+ }
+ while (i >= is_neg ? 1 : 0)
+ {
+ i--;
+ s[is_neg ? i + 1 : i] = base[num % radix];
+ num /= radix;
+ }
+ return (s);
+}
+
+int ft_atoi_skip(char **s)
+{
+ long num;
+
+ num = 0;
+ while (**s >= '0' && **s <= '9')
+ {
+ num *= 10;
+ num += **s - '0';
+ (*s)++;
+ }
+ return ((int)num);
+}
+
+typedef struct
+{
+ int precision;
+ int width;
+} t_parsing;
+
+char *parse(t_parsing *parsing, char *fmt)
+{
+ parsing->precision = -1;
+ parsing->width = -1;
+
+ if (*fmt >= '0' && *fmt <= '9')
+ parsing->width = ft_atoi_skip(&fmt);
+ if (*fmt == '.')
+ {
+ fmt++;
+ parsing->precision = ft_atoi_skip(&fmt);
+ }
+ return (fmt);
+}
+
+int convert_str(va_list ap, t_parsing *parsing)
+{
+ int written;
+ char *tmp;
+ char *str;
+ int is_null;
+
+ str = va_arg(ap, char*);
+ is_null = str == NULL;
+ if (str == NULL)
+ if ((str = ft_strdup("(null)")) == NULL)
+ return (-1);
+ if (parsing->precision != -1 && ft_strlen(str) > parsing->precision)
+ {
+ if ((tmp = ft_strdup(str)) == NULL)
+ return (-1);
+ tmp[parsing->precision] = '\0';
+ str = tmp;
+ }
+ written = ft_strlen(str);
+ if (parsing->width != -1)
+ {
+ while (ft_strlen(str) < parsing->width)
+ {
+ ft_putchar(' ');
+ parsing->width--;
+ written++;
+ }
+ }
+ ft_putstr(str);
+ if (parsing->precision != -1 || is_null)
+ free(str);
+ return (written);
+}
+
+int convert_d(va_list ap, t_parsing *parsing)
+{
+ int i;
+ int len;
+ long int num;
+ char *s;
+ char *tmp;
+
+ num = va_arg(ap, int);
+ if ((s = ft_itoa_base(num, "0123456789")) == NULL)
+ return (-1);
+ len = ft_strlen(s);
+ if (parsing->precision != -1 && len < parsing->precision)
+ {
+ if ((tmp = malloc(parsing->precision + 10)) == NULL)
+ return (-1);
+ ft_strcpy(tmp + parsing->precision - len, s);
+ i = 0;
+ while (i < parsing->precision - len)
+ {
+ tmp[i] = '0';
+ i++;
+ }
+ s = tmp;
+ }
+ len = ft_strlen(s);
+ if (parsing->width != -1 && len < parsing->width)
+ {
+ while (len < parsing->width)
+ {
+ ft_putchar(' ');
+ len++;
+ }
+ }
+ ft_putstr(s);
+ free(s);
+ return (len);
+}
+
+int convert_x(va_list ap, t_parsing *parsing)
+{
+ int i;
+ int len;
+ long unsigned int num;
+ char *s;
+ char *tmp;
+
+ num = va_arg(ap, unsigned int);
+ if ((s = ft_itoa_base(num, "0123456789abcdef")) == NULL)
+ return (-1);
+ len = ft_strlen(s);
+ if (parsing->precision != -1 && len < parsing->precision)
+ {
+ if ((tmp = malloc(parsing->precision + 1)) == NULL)
+ return (-1);
+ ft_strcpy(tmp + parsing->precision - len, s);
+ i = 0;
+ while (i < parsing->precision - len)
+ {
+ tmp[i] = '0';
+ i++;
+ }
+ free(s);
+ s = tmp;
+ }
+ len = ft_strlen(s);
+ if (parsing->width != -1 && len < parsing->width)
+ {
+ while (len < parsing->width)
+ {
+ ft_putchar(' ');
+ len++;
+ }
+ }
+ ft_putstr(s);
+ if (parsing->precision == -1)
+ free(s);
+// free(s);
+ return (len);
+}
+
+int ft_printf(const char *fmt, ... )
+{
+ t_parsing parsing;
+ va_list ap;
+ int i;
+ int tmp;
+
+ va_start(ap, fmt);
+ i = 0;
+ while (*fmt)
+ {
+ if (*fmt == '%')
+ {
+ fmt = parse(&parsing, (char*)++fmt);
+ if (*fmt == 's')
+ i += convert_str(ap, &parsing);
+ else if (*fmt == 'd')
+ i += convert_d(ap, &parsing);
+ else if (*fmt == 'x')
+ i += convert_x(ap, &parsing);
+ fmt++;
+ }
+ else
+ {
+ ft_putchar(*fmt);
+ fmt++;
+ i++;
+ }
+ }
+ va_end(ap);
+ return (i);
+}
diff --git a/rendu/inter/inter.c b/rendu/inter/inter.c
new file mode 100755
index 0000000..1d5eeff
--- /dev/null
+++ b/rendu/inter/inter.c
@@ -0,0 +1,60 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* iter.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: exam <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:00:51 by exam #+# #+# */
+/* Updated: 2020/02/14 17:13:39 by exam ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+int ft_strlen(char *s)
+{
+ int i;
+
+ i = 0;
+ while (s[i])
+ i++;
+ return (i);
+}
+
+void ft_putchar(char c)
+{
+ write(1, &c, 1);
+}
+
+int in_str(char *s, char c, int n)
+{
+ while (*s && n-- > 0)
+ if (c == *s++)
+ return (1);
+ return (0);
+}
+
+int main(int argc, char **argv)
+{
+ char *s1;
+ char *s2;
+ int i;
+
+ if (argc != 3)
+ {
+ write(1, "\n", 1);
+ return (1);
+ }
+ s1 = argv[1];
+ s2 = argv[2];
+ i = 0;
+ while (s1[i])
+ {
+ if (!in_str(s1, s1[i], i) && in_str(s2, s1[i], ft_strlen(s2)))
+ ft_putchar(s1[i]);
+ i++;
+ }
+ ft_putchar('\n');
+ return (0);
+}