-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposnumbin.c
27 lines (25 loc) · 1.12 KB
/
posnumbin.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* posnumbin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yst-laur <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/09 14:20:49 by yst-laur #+# #+# */
/* Updated: 2022/03/09 14:20:53 by yst-laur ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
char *posnumbin(unsigned long long n, char *str, int maxwidth)
{
const char *base;
base = "01";
str[maxwidth] = '\0';
while (maxwidth > 0)
{
str[maxwidth - 1] = base[n % 2];
n = n / 2;
maxwidth--;
}
return (str);
}