init
This commit is contained in:
		
							
								
								
									
										45
									
								
								C/c07v1/ex00/ft_strdup.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								C/c07v1/ex00/ft_strdup.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/*                                                        :::      ::::::::   */
 | 
			
		||||
/*   ft_strdup.c                                        :+:      :+:    :+:   */
 | 
			
		||||
/*                                                    +:+ +:+         +:+     */
 | 
			
		||||
/*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */
 | 
			
		||||
/*                                                +#+#+#+#+#+   +#+           */
 | 
			
		||||
/*   Created: 2022/07/22 09:56:34 by cchauvet          #+#    #+#             */
 | 
			
		||||
/*   Updated: 2022/07/26 17:58:31 by cchauvet         ###   ########.fr       */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
char	*ft_strcpy(char *dest, char *src)
 | 
			
		||||
{
 | 
			
		||||
	int	i;
 | 
			
		||||
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (src[i] != 0)
 | 
			
		||||
	{
 | 
			
		||||
		dest[i] = src[i];
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
	return (dest);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned int	ft_strlen(char *str)
 | 
			
		||||
{
 | 
			
		||||
	unsigned int	i;
 | 
			
		||||
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (str[i] != 0)
 | 
			
		||||
		i++;
 | 
			
		||||
	return (i);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char	*ft_strdup(char *src)
 | 
			
		||||
{
 | 
			
		||||
	char	*dest;
 | 
			
		||||
 | 
			
		||||
	dest = malloc(sizeof(src) * ft_strlen(src));
 | 
			
		||||
	ft_strcpy(dest, src);
 | 
			
		||||
	return (dest);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								C/c07v1/ex01/ft_range.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								C/c07v1/ex01/ft_range.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/*                                                        :::      ::::::::   */
 | 
			
		||||
/*   ft_range.c                                         :+:      :+:    :+:   */
 | 
			
		||||
/*                                                    +:+ +:+         +:+     */
 | 
			
		||||
/*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */
 | 
			
		||||
/*                                                +#+#+#+#+#+   +#+           */
 | 
			
		||||
/*   Created: 2022/07/21 18:54:20 by cchauvet          #+#    #+#             */
 | 
			
		||||
/*   Updated: 2022/07/26 17:57:51 by cchauvet         ###   ########.fr       */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
int	*ft_range(int min, int max)
 | 
			
		||||
{
 | 
			
		||||
	int	i;
 | 
			
		||||
	int	*tab;
 | 
			
		||||
 | 
			
		||||
	*tab = NULL;
 | 
			
		||||
	if (max <= min)
 | 
			
		||||
		return (tab);
 | 
			
		||||
	tab = malloc(sizeof(*tab) * (max - min));
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (min + i < max)
 | 
			
		||||
	{
 | 
			
		||||
		*(tab + i) = min + i;
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
	return (tab);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										30
									
								
								C/c07v1/ex02/ft_ultimate_range.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								C/c07v1/ex02/ft_ultimate_range.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/*                                                        :::      ::::::::   */
 | 
			
		||||
/*   ft_ultimate_range.c                                :+:      :+:    :+:   */
 | 
			
		||||
/*                                                    +:+ +:+         +:+     */
 | 
			
		||||
/*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */
 | 
			
		||||
/*                                                +#+#+#+#+#+   +#+           */
 | 
			
		||||
/*   Created: 2022/07/22 10:33:24 by cchauvet          #+#    #+#             */
 | 
			
		||||
/*   Updated: 2022/07/26 17:50:02 by cchauvet         ###   ########.fr       */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
int	ft_ultimate_range(int **range, int min, int max)
 | 
			
		||||
{
 | 
			
		||||
	int	i;
 | 
			
		||||
 | 
			
		||||
	*range = NULL;
 | 
			
		||||
	if (max <= min)
 | 
			
		||||
		return (0);
 | 
			
		||||
	*range = malloc(sizeof(*range) * (max - min));
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (min + i < max)
 | 
			
		||||
	{
 | 
			
		||||
		(*range)[i] = min + i;
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
	return (max - min);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										69
									
								
								C/c07v1/ex03/ft_strjoin.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								C/c07v1/ex03/ft_strjoin.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/*                                                        :::      ::::::::   */
 | 
			
		||||
/*   ft_strjoin.c                                       :+:      :+:    :+:   */
 | 
			
		||||
/*                                                    +:+ +:+         +:+     */
 | 
			
		||||
/*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */
 | 
			
		||||
/*                                                +#+#+#+#+#+   +#+           */
 | 
			
		||||
/*   Created: 2022/07/24 13:29:37 by cchauvet          #+#    #+#             */
 | 
			
		||||
/*   Updated: 2022/07/24 14:44:52 by cchauvet         ###   ########.fr       */
 | 
			
		||||
/*                                                                            */
 | 
			
		||||
/* ************************************************************************** */
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
int	ft_strlen(char *str)
 | 
			
		||||
{
 | 
			
		||||
	char	i;
 | 
			
		||||
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (str[i] != 0)
 | 
			
		||||
		i++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char	*ft_strcat(char *dest, char *src)
 | 
			
		||||
{
 | 
			
		||||
	int	i;
 | 
			
		||||
	int	j;
 | 
			
		||||
 | 
			
		||||
	j = 0;
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (dest[i] != 0)
 | 
			
		||||
		i++;
 | 
			
		||||
	while (src[j] != 0)
 | 
			
		||||
	{
 | 
			
		||||
		dest[i + j] = src[j];
 | 
			
		||||
		j++;
 | 
			
		||||
	}
 | 
			
		||||
	dest[i + j] = 0;
 | 
			
		||||
	return (dest);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char	*ft_strjoin(int size, char **strs, char *sep)
 | 
			
		||||
{
 | 
			
		||||
	int		i;
 | 
			
		||||
	int		word_counter;
 | 
			
		||||
	char	*out;
 | 
			
		||||
 | 
			
		||||
	if (size == 0)
 | 
			
		||||
	{
 | 
			
		||||
		*out = malloc(sizeof(*out));
 | 
			
		||||
		*out = "";
 | 
			
		||||
		return (out);
 | 
			
		||||
	}
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (i < size)
 | 
			
		||||
	{
 | 
			
		||||
		word_counter += ft_strlen(strs[i]);
 | 
			
		||||
		word_counter += ft_strlen(sep);
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
	out = malloc(sizeof(*out) * word_counter);
 | 
			
		||||
	i = 0;
 | 
			
		||||
	while (i < size)
 | 
			
		||||
	{
 | 
			
		||||
		ft_strcat(out, strs[i++]);
 | 
			
		||||
		ft_strcat(out, sep);
 | 
			
		||||
	}
 | 
			
		||||
	return (out);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								C/c07v1/ex04/.ft_split.c.swp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								C/c07v1/ex04/.ft_split.c.swp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user