diff --git a/c03/ex00.c b/c03/ex00.c new file mode 100644 index 0000000..95e9f9a --- /dev/null +++ b/c03/ex00.c @@ -0,0 +1,45 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ex00.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/29 19:42:18 by achubuko #+# #+# */ +/* Updated: 2023/11/29 22:09:07 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#define TEST_BUF_SIZE 100 + +int ft_strcmp(char *s1, char *s2); + +int main(void) +{ + char s[TEST_BUF_SIZE] = "Hello World!"; + char d1[TEST_BUF_SIZE] = "Hello World!"; + char d2[TEST_BUF_SIZE] = "Hello Sarld!"; + int r1; + int r2; + + printf("initial strings:\n"); + dump(s, 20); + dump(d1, 20); + dump(d2, 20); + + printf("strcmp(d2, s):\n"); + r1 = strcmp(d2, s); + r2 = ft_strcmp(d2, s); + printf("return values: orig: %i ft: %i\n", r1, r2); + printf("strcmp(s, d2):\n"); + r1 = strcmp(s, d2); + r2 = ft_strcmp(s, d2); + printf("return values: orig: %i ft: %i\n", r1, r2); + printf("strcmp(s, d1):\n"); + r1 = strcmp(s, d1); + r2 = ft_strcmp(s, d1); + printf("return values: orig: %i ft: %i\n", r1, r2); + return 0; +} diff --git a/c03/ex01.c b/c03/ex01.c new file mode 100644 index 0000000..a3fb1b1 --- /dev/null +++ b/c03/ex01.c @@ -0,0 +1,51 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ex00.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/29 19:42:18 by achubuko #+# #+# */ +/* Updated: 2023/11/29 22:14:59 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#define TEST_BUF_SIZE 100 + +int ft_strncmp(char *s1, char *s2, unsigned int n); + +int main(void) +{ + char s[TEST_BUF_SIZE] = "Hello World!"; + char d1[TEST_BUF_SIZE] = "Hello World!"; + char d2[TEST_BUF_SIZE] = "Hello Sarld!"; + char d3[TEST_BUF_SIZE] = "Hell"; + int r1; + int r2; + + printf("initial strings:\n"); + dump(s, 20); + dump(d1, 20); + dump(d2, 20); + dump(d3, 20); + + printf("strncmp(d2, s, 5):\n"); + r1 = strncmp(d2, s, 5); + r2 = ft_strncmp(d2, s, 5); + printf("return values: orig: %i ft: %i\n", r1, r2); + printf("strncmp(s, d2, 20):\n"); + r1 = strncmp(s, d2, 20); + r2 = ft_strncmp(s, d2, 20); + printf("return values: orig: %i ft: %i\n", r1, r2); + printf("strncmp(s, d1, 15):\n"); + r1 = strncmp(s, d1, 15); + r2 = ft_strncmp(s, d1, 15); + printf("return values: orig: %i ft: %i\n", r1, r2); + printf("strncmp(s, d3, 15):\n"); + r1 = strncmp(s, d3, 15); + r2 = ft_strncmp(s, d3, 15); + printf("return values: orig: %i ft: %i\n", r1, r2); + return 0; +}