aboutsummaryrefslogtreecommitdiff
path: root/c09
diff options
context:
space:
mode:
Diffstat (limited to 'c09')
-rw-r--r--c09/ex00/ft_strcmp.c4
-rw-r--r--c09/ex00/ft_strlen.c5
-rwxr-xr-xc09/ex00/libft_creator.sh2
-rw-r--r--c09/ex01/Makefile23
-rw-r--r--c09/ex01/srcs/ft_putchar.c2
-rw-r--r--c09/ex01/srcs/ft_putstr.c3
-rw-r--r--c09/ex02/ft_split.c7
-rw-r--r--c09/main.c27
8 files changed, 56 insertions, 17 deletions
diff --git a/c09/ex00/ft_strcmp.c b/c09/ex00/ft_strcmp.c
index 8870811..18f975a 100644
--- a/c09/ex00/ft_strcmp.c
+++ b/c09/ex00/ft_strcmp.c
@@ -6,11 +6,11 @@
/* 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 */
+/* Updated: 2019/07/16 09:37:13 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
-int ft_strcmp(char *s1, char *s2)
+int ft_strcmp(char *s1, char *s2)
{
while (*s1 == *s2 && *s1 && *s2)
{
diff --git a/c09/ex00/ft_strlen.c b/c09/ex00/ft_strlen.c
index 91e6948..fe5f4b7 100644
--- a/c09/ex00/ft_strlen.c
+++ b/c09/ex00/ft_strlen.c
@@ -6,11 +6,11 @@
/* 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 */
+/* Updated: 2019/07/16 09:36:56 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
-int ft_strlen(char *str)
+int ft_strlen(char *str)
{
int i;
@@ -19,4 +19,3 @@ int ft_strlen(char *str)
i++;
return (i);
}
-
diff --git a/c09/ex00/libft_creator.sh b/c09/ex00/libft_creator.sh
index 9c0aefa..796b263 100755
--- a/c09/ex00/libft_creator.sh
+++ b/c09/ex00/libft_creator.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-gcc -c ft_putchar.c ft_swap.c ft_putstr.c ft_strlen.c ft_strcmp.c
+gcc -Wall -Wextra -Werror -c ft_putchar.c ft_swap.c ft_putstr.c ft_strlen.c ft_strcmp.c
ar -rs libft.a ft_putchar.o ft_swap.o ft_putstr.o ft_strlen.o ft_strcmp.o
rm -f ft_putchar.o ft_swap.o ft_putstr.o ft_strlen.o ft_strcmp.o
diff --git a/c09/ex01/Makefile b/c09/ex01/Makefile
index ba69535..3547e9c 100644
--- a/c09/ex01/Makefile
+++ b/c09/ex01/Makefile
@@ -1,6 +1,19 @@
+# **************************************************************************** #
+# #
+# ::: :::::::: #
+# Makefile :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2019/07/15 19:27:49 by cacharle #+# #+# #
+# Updated: 2019/07/16 07:41:31 by cacharle ### ########.fr #
+# #
+# **************************************************************************** #
+
OUT = libft.a
CC = gcc
CCFLAGS = -Wall -Wextra -Werror
+LDFLAGS = -Iincludes
OBJ = srcs/ft_putchar.o srcs/ft_swap.o srcs/ft_putstr.o srcs/ft_strlen.o srcs/ft_strcmp.o
.PHONY: all
@@ -10,19 +23,19 @@ $(OUT): $(OBJ)
ar -crs $(OUT) $(OBJ)
srcs/ft_putchar.o: srcs/ft_putchar.c includes/ft.h
- $(CC) $(CCFLAGS) -c $< -o $@
+ $(CC) $(CCFLAGS) $(LDFLAGS) -c $< -o $@
srcs/ft_swap.o: srcs/ft_swap.c includes/ft.h
- $(CC) $(CCFLAGS) -c $< -o $@
+ $(CC) $(CCFLAGS) $(LDFLAGS) -c $< -o $@
srcs/ft_putstr.o: srcs/ft_putstr.c includes/ft.h
- $(CC) $(CCFLAGS) -c $< -o $@
+ $(CC) $(CCFLAGS) $(LDFLAGS) -c $< -o $@
srcs/ft_strlen.o: srcs/ft_strlen.c includes/ft.h
- $(CC) $(CCFLAGS) -c $< -o $@
+ $(CC) $(CCFLAGS) $(LDFLAGS) -c $< -o $@
srcs/ft_strcmp.o: srcs/ft_strcmp.c includes/ft.h
- $(CC) $(CCFLAGS) -c $< -o $@
+ $(CC) $(CCFLAGS) $(LDFLAGS) -c $< -o $@
.PHONY: clean
clean:
diff --git a/c09/ex01/srcs/ft_putchar.c b/c09/ex01/srcs/ft_putchar.c
index 8a53dc8..51b252e 100644
--- a/c09/ex01/srcs/ft_putchar.c
+++ b/c09/ex01/srcs/ft_putchar.c
@@ -6,7 +6,7 @@
/* 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 */
+/* Updated: 2019/07/15 13:18:04 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/c09/ex01/srcs/ft_putstr.c b/c09/ex01/srcs/ft_putstr.c
index c4f4564..fef1aac 100644
--- a/c09/ex01/srcs/ft_putstr.c
+++ b/c09/ex01/srcs/ft_putstr.c
@@ -6,11 +6,12 @@
/* 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 */
+/* Updated: 2019/07/16 07:29:45 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
+#include "ft.h"
void ft_putstr(char *str)
{
diff --git a/c09/ex02/ft_split.c b/c09/ex02/ft_split.c
index e1c0186..a11477f 100644
--- a/c09/ex02/ft_split.c
+++ b/c09/ex02/ft_split.c
@@ -6,7 +6,7 @@
/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/08 15:58:03 by cacharle #+# #+# */
-/* Updated: 2019/07/15 09:21:14 by cacharle ### ########.fr */
+/* Updated: 2019/07/16 09:18:23 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -62,7 +62,8 @@ char **heck(char *str, char *charset, char *tmp, int i)
while (!in_charset(*str, charset) && *str)
tmp[i++] = *str++;
tmp[i] = '\0';
- strs[j++] = tmp;
+ if (i != 0)
+ strs[j++] = tmp;
}
strs[j] = 0;
return (strs);
@@ -70,7 +71,5 @@ char **heck(char *str, char *charset, char *tmp, int i)
char **ft_split(char *str, char *charset)
{
- if (!*str)
- return (NULL);
return (heck(str, charset, NULL, 0));
}
diff --git a/c09/main.c b/c09/main.c
new file mode 100644
index 0000000..02c5a61
--- /dev/null
+++ b/c09/main.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ex02/ft_split.c"
+
+int main()
+{
+ char *const str = "3YaZkAP30iGoBWv L asdf h LbpX8Hx FWHwB2u1FH0S5";
+ char *begin = "\n \t hgonjour";
+ char *end = "jesuis\n\t hhh";
+ char *empty = " h bonjour je suis ";
+ char *charset = "\n\t";
+ char **strs = ft_split(end, charset);
+ printf("tab start\n");
+ for (int i = 0; strs[i] != 0; i++)
+ {
+ printf("tab[%d]: %s\n", i, strs[i]);
+ /*for (int j = 0; j < 10; j++)*/
+ /*printf("%d ", strs[i][j]);*/
+ }
+ printf("tab end\n");
+ for (int i = 0; strs[i] != 0; i++)
+ free(strs[i]);
+ free(strs);
+
+ return 0;
+}