-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add (libft): some string funcs and repo improvements
- Loading branch information
Showing
11 changed files
with
193 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# ide settings | ||
.vscode/ | ||
|
||
# builds and objects | ||
*.out | ||
*.o | ||
*.o | ||
|
||
# ignore the subjects | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
NAME = libft | ||
|
||
CC = gcc | ||
FLAGS = -Wall -Wextra -Werror | ||
|
||
SRC = ft_isalpha.c \ | ||
ft_isdigit.c \ | ||
ft_isalnum.c \ | ||
ft_isascii.c \ | ||
ft_isprint.c \ | ||
ft_strlen.c \ | ||
ft_strlcpy.c \ | ||
ft_strlcat.c \ | ||
ft_bzero.c \ | ||
ft_memset.c \ | ||
ft_memcpy.c \ | ||
ft_memcmp.c \ | ||
ft_memchr.c | ||
INC = libft.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_memchr.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: ebabaogl <ebabaogl@student.42kocaeli.co +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/04/26 15:41:55 by ebabaogl #+# #+# */ | ||
/* Updated: 2024/04/26 16:39:47 by ebabaogl ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft.h" | ||
|
||
void *ft_memchr(const void *s, int c, size_t n) | ||
{ | ||
unsigned char *p; | ||
|
||
p = (unsigned char *)s; | ||
while (n > 0) | ||
{ | ||
if (*p == (unsigned char)c) | ||
return (c); | ||
p++; | ||
n--; | ||
} | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_memcmp.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: ebabaogl <ebabaogl@student.42kocaeli.co +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/04/26 15:52:23 by ebabaogl #+# #+# */ | ||
/* Updated: 2024/04/26 16:22:07 by ebabaogl ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft.h" | ||
|
||
int ft_memcmp(const void *s1, const void *s2, size_t n) | ||
{ | ||
unsigned char *p1; | ||
unsigned char *p2; | ||
|
||
p1 = (unsigned char *)s1; | ||
p2 = (unsigned char *)s2; | ||
while (n > 0) | ||
{ | ||
if (*p1 > *p2) | ||
return (1); | ||
else if (*p1 < *p2) | ||
return (-1); | ||
else | ||
{ | ||
p1++; | ||
p2++; | ||
} | ||
n--; | ||
} | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_memmove.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: ebabaogl <ebabaogl@student.42kocaeli.co +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/04/26 14:19:12 by ebabaogl #+# #+# */ | ||
/* Updated: 2024/04/26 16:52:43 by ebabaogl ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft.h" | ||
|
||
void *ft_memmove(void *dest, const void *src, size_t n) | ||
{ | ||
return (dest); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_strlcat.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: ebabaogl <ebabaogl@student.42kocaeli.co +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/04/26 17:44:34 by ebabaogl #+# #+# */ | ||
/* Updated: 2024/04/26 18:42:56 by ebabaogl ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft.h" | ||
|
||
size_t ft_strlcat(char *dst, const char *src, size_t size) | ||
{ | ||
size_t i; | ||
size_t j; | ||
|
||
i = 0; | ||
j = 0; | ||
while (i < size && dst[i]) | ||
i++; | ||
while ((i + j + 1) < size && src[j]) | ||
{ | ||
dst[i + j] = src[j]; | ||
j++; | ||
} | ||
if (i != size) | ||
dst[i + j] = '\0'; | ||
return (i + ft_strlen(src)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_strlcpy.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: ebabaogl <ebabaogl@student.42kocaeli.co +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/04/26 16:57:33 by ebabaogl #+# #+# */ | ||
/* Updated: 2024/04/26 17:44:22 by ebabaogl ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft.h" | ||
|
||
size_t ft_strlcpy(char *dest, const char *src, size_t size) | ||
{ | ||
size_t c; | ||
|
||
c = 0; | ||
if (size != 0) | ||
{ | ||
while (src[c] && c < (size - 1)) | ||
{ | ||
dest[c] = src[c]; | ||
c++; | ||
} | ||
dest[c] = '\0'; | ||
} | ||
return (ft_strlen(src)); | ||
} | ||
|
||
/* | ||
strcpy: src uzun olursa | ||
strncpy: n > len(dst) && len(src) > len(dst) | ||
strlcpy: n > len(dst) && len(src) > len(dst) | ||
zattiri zort zort oluyo bu durumlarda | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters