Skip to content

Commit

Permalink
code organization changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeSinLiang committed Jun 27, 2023
1 parent 06b5a57 commit 18e7d0d
Show file tree
Hide file tree
Showing 47 changed files with 31 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: make
run: make
- name: make all
run: make all
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SRCS_DIR = src/
SRCS = ft_atoi.c \
ft_bzero.c \
ft_calloc.c \
Expand Down Expand Up @@ -44,15 +45,18 @@ SRCS_B = ft_lstadd_back.c \
ft_lstsize.c


OBJS = ${SRCS:.c=.o}
OBJS_B = ${SRCS_B:.c=.o}
INCS = includes
CFILES = $(addprefix $(SRCS_DIR), $(SRCS))
CFILES_B = $(addprefix $(SRCS_DIR), $(SRCS_B))

OBJS = ${CFILES:.c=.o}
OBJS_B = ${CFILES_B:.c=.o}
INCS = ./inc
NAME = libft.a
LIBC = ar rcs
LIBR = ranlib
CC = gcc
RM = rm -f
CFLAGS = -Wall -Wextra -Werror
CFLAGS = -std=c11 -Wall -Wextra -Werror -I$(INCS)


all: ${NAME}
Expand Down
2 changes: 2 additions & 0 deletions libft.h → inc/libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# include <string.h>
# include <unistd.h>
# include <stdbool.h>
# include <limits.h>
# include <stdint.h>

typedef struct s_list
{
Expand Down
19 changes: 19 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
char **ft_split(char const *s, char c);

#include <stdio.h>
int main(int argc, char **argv)
{
int index;
char **split;

split = ft_split(argv[1], argv[2][0]);
index = 0;
printf("tab start\n");
while (split[index])
{
printf("tab[%d]: $%s$\n", index, split[index]);
fflush(stdout);
index++;
}
printf("tab end\n");
}
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions ft_calloc.c → src/ft_calloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
void *ft_calloc(size_t count, size_t size)
{
void *ptr;
size_t i;

i = 0;
if (count == SIZE_MAX || size == SIZE_MAX)
return (NULL);
ptr = malloc(count * size);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions ft_split.c → src/ft_split.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ static bool check_seperator(char c_str, char c)

static int count_strings(char *str, char c)
{
int i;
int count;

i = 0;
count = 0;
while (*str)
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 18e7d0d

Please sign in to comment.