aboutsummaryrefslogtreecommitdiff
path: root/c09
diff options
context:
space:
mode:
Diffstat (limited to 'c09')
-rw-r--r--c09/ex00/ft_putchar.c18
-rw-r--r--c09/ex00/ft_putstr.c19
-rw-r--r--c09/ex00/ft_strcmp.c21
-rw-r--r--c09/ex00/ft_strlen.c22
-rw-r--r--c09/ex00/ft_swap.c20
-rw-r--r--c09/ex00/libft_creator.sh3
-rw-r--r--c09/ex01/Makefile28
7 files changed, 131 insertions, 0 deletions
diff --git a/c09/ex00/ft_putchar.c b/c09/ex00/ft_putchar.c
new file mode 100644
index 0000000..8a53dc8
--- /dev/null
+++ b/c09/ex00/ft_putchar.c
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_putchar.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/02 22:03:32 by cacharle #+# #+# */
+/* Updated: 2019/07/03 14:21:40 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+void ft_putchar(char c)
+{
+ write(1, &c, 1);
+}
diff --git a/c09/ex00/ft_putstr.c b/c09/ex00/ft_putstr.c
new file mode 100644
index 0000000..c4f4564
--- /dev/null
+++ b/c09/ex00/ft_putstr.c
@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_putstr.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/11 16:17:16 by cacharle #+# #+# */
+/* Updated: 2019/07/11 16:18:11 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+void ft_putstr(char *str)
+{
+ while (*str)
+ write(1, str++, 1);
+}
diff --git a/c09/ex00/ft_strcmp.c b/c09/ex00/ft_strcmp.c
new file mode 100644
index 0000000..8870811
--- /dev/null
+++ b/c09/ex00/ft_strcmp.c
@@ -0,0 +1,21 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strcmp.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/11 16:20:33 by cacharle #+# #+# */
+/* Updated: 2019/07/11 16:21:55 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+int ft_strcmp(char *s1, char *s2)
+{
+ while (*s1 == *s2 && *s1 && *s2)
+ {
+ s1++;
+ s2++;
+ }
+ return (*s1 - *s2);
+}
diff --git a/c09/ex00/ft_strlen.c b/c09/ex00/ft_strlen.c
new file mode 100644
index 0000000..91e6948
--- /dev/null
+++ b/c09/ex00/ft_strlen.c
@@ -0,0 +1,22 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strlen.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/11 16:19:43 by cacharle #+# #+# */
+/* Updated: 2019/07/11 16:20:18 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+int ft_strlen(char *str)
+{
+ int i;
+
+ i = 0;
+ while (str[i])
+ i++;
+ return (i);
+}
+
diff --git a/c09/ex00/ft_swap.c b/c09/ex00/ft_swap.c
new file mode 100644
index 0000000..989b2c2
--- /dev/null
+++ b/c09/ex00/ft_swap.c
@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_swap.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/11 16:18:42 by cacharle #+# #+# */
+/* Updated: 2019/07/11 16:19:31 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+void ft_swap(int *a, int *b)
+{
+ int tmp;
+
+ tmp = *a;
+ *a = *b;
+ *b = tmp;
+}
diff --git a/c09/ex00/libft_creator.sh b/c09/ex00/libft_creator.sh
new file mode 100644
index 0000000..f799ee2
--- /dev/null
+++ b/c09/ex00/libft_creator.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+gcc -c *.c
+ar -rcs libft.a *.o
diff --git a/c09/ex01/Makefile b/c09/ex01/Makefile
new file mode 100644
index 0000000..0fec395
--- /dev/null
+++ b/c09/ex01/Makefile
@@ -0,0 +1,28 @@
+SRCDIR = srcs
+SRC = ft_putchar.c ft_swap.c ft_putstr.c ft_strlen.c ft_strcmp.c
+OBJ = $(SRC:.c = .o)
+INCLUDEDIR = includes
+INCLUDES = ft.h
+CC = gcc
+CCFLAGS = -Wall -Wextra -Werror
+OUT = libft.a
+
+all: OUT
+.PHONY: all
+
+$(OUT): $(OBJ)
+ ar -crs $(OBJ)
+
+$(OBJ): %.o: %.c
+ $(CC) $(CCFLAGS) -c $< -o $@
+
+.PHONY: clean
+clean:
+ rm -f srcs/*.o
+
+.PHONY: fclean
+fclean: clean
+ rm $(OUT)
+
+.PHONY: re
+re: fclean all