Skip to content

Commit

Permalink
Makefile for printf is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
hatalhao committed Nov 24, 2023
1 parent 7704ea7 commit ef714c0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME = libft.a
NAME = libftprintf.a

CC = cc

Expand All @@ -8,7 +8,7 @@ SRCS = ft_itoa.c ft_putstr_fd.c ft_strmapi.c ft_atoi.c ft_memchr.c ft_split.c ft
ft_bzero.c ft_memcmp.c ft_strchr.c ft_strnstr.c ft_calloc.c ft_memcpy.c ft_strdup.c ft_strrchr.c \
ft_isalnum.c ft_memmove.c ft_striteri.c ft_strtrim.c ft_isalpha.c ft_memset.c ft_strjoin.c \
ft_substr.c ft_isascii.c ft_putchar_fd.c ft_strlcat.c ft_tolower.c ft_isdigit.c \
ft_putendl_fd.c ft_strlcpy.c ft_toupper.c ft_isprint.c ft_putnbr_fd.c ft_strlen.c
ft_putendl_fd.c ft_strlcpy.c ft_toupper.c ft_isprint.c ft_putnbr_fd.c ft_strlen.c ft_printf.c

OBJS = $(SRCS:.c=.o)

Expand Down
36 changes: 36 additions & 0 deletions ft_pc_printf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_pc_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hatalhao <hatalha@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/24 11:55:24 by talhaoui #+# #+# */
/* Updated: 2023/11/24 11:55:24 by talhaoui ### ########.fr */
/* */
/* ************************************************************************** */


#include "ft_printf.h"

int ft_printf(char const *str, ...)
{
int i;

i = 0;
va_list(args);
va_start(args, str);
while (str[i])
{
ft_putchar_fd(str[i], 1);
if (str[i] == '%')
{
if (str[++i] == '%')
str[i] = '%';
if (str[++i] == 's')
str + i = ft_putstr_fd(va_arg(args, char *), 1);
}
}
va_end(args);
return (i);
}
8 changes: 8 additions & 0 deletions ft_printf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#ifndef FT_PRINTF_H
# define FT_PRINTF_H

# include "libft.h"


#endif
4 changes: 2 additions & 2 deletions ft_putstr_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hatalhao <marvin@42.fr> +#+ +:+ +#+ */
/* By: talhaoui <talhaoui@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 17:39:45 by hatalhao #+# #+# */
/* Updated: 2023/11/03 17:41:02 by hatalhao ### ########.fr */
/* Updated: 2023/11/24 15:39:35 by talhaoui ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
8 changes: 6 additions & 2 deletions libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* libft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hatalhao <marvin@42.fr> +#+ +:+ +#+ */
/* By: talhaoui <talhaoui@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 18:16:47 by hatalhao #+# #+# */
/* Updated: 2023/11/04 20:58:39 by hatalhao ### ########.fr */
/* Updated: 2023/11/24 16:37:23 by talhaoui ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -18,6 +18,8 @@
# include <stdio.h>
# include <string.h>
# include <limits.h>
# include <stdarg.h>


int ft_isalpha(int c);
int ft_isdigit(int c);
Expand All @@ -30,6 +32,8 @@ int ft_atoi(char const *nptr);
int ft_memcmp(const void *s1, const void *s2, size_t n);
int ft_strncmp(char const *s1, char const *s2, size_t n);

int ft_printf(char const *, ...);

char *ft_itoa(int n);
char *ft_strdup(char const *src);
char *ft_strchr(char const *s, int c);
Expand Down

0 comments on commit ef714c0

Please sign in to comment.