-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpad_right.c
More file actions
31 lines (28 loc) · 1.15 KB
/
pad_right.c
File metadata and controls
31 lines (28 loc) · 1.15 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pad_right.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hiroshiusui <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/01/31 02:37:58 by hiroshius #+# #+# */
/* Updated: 2018/01/31 02:37:59 by hiroshius ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *pad_right(char *str, int n, char c)
{
int i;
int length;
char *new;
length = ft_strlen(str);
if (length >= n)
return (str);
new = ft_strnew(n);
i = 0;
while (i < length)
new[i++] = *str++;
while (i < n)
new[i++] = c;
return (new);
}