aboutsummaryrefslogtreecommitdiffstats
path: root/libft/src/ft_nstr.c
blob: 2d5fc85a7ac4fdcdae79232646ca68e3ddd4e718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_nstr.c                                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: joelecle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:06:43 by joelecle          #+#    #+#             */
/*   Updated: 2020/02/14 17:06:43 by joelecle         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <stdlib.h>
#include <stddef.h>

char
	*ft_nstr(size_t size)
{
	char		*str;
	size_t		i;

	i = 0;
	size += 1;
	if (!(str = (char*)malloc((size) * sizeof(char))))
		return (NULL);
	while (i < size)
	{
		str[i] = '\0';
		i++;
	}
	return (str);
}