NEW
This commit is contained in:
parent
a5b26ddff4
commit
2f121d0be1
|
@ -1,6 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#define STR1 "abd"
|
||||
#define STR2 "abc"
|
||||
#define STR1 "a"
|
||||
#define STR2 "a"
|
||||
#define LENGTH 0
|
||||
|
||||
int main(void)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <bsd/string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[10] = "123";
|
||||
char s[10] = "aaaa";
|
||||
|
||||
printf("%d\n", ft_strlcat(s, "abc", 5));
|
||||
printf("%d\n", ft_strlcat(s, "xyz", 16));
|
||||
printf("%s\n", s);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -2,47 +2,47 @@
|
|||
|
||||
int main(void)
|
||||
{
|
||||
printf("Input:<> Output:<%d>\n", ft_atoi(""));
|
||||
printf("Input:<0> Output:<%d>\n", ft_atoi("0"));
|
||||
printf("Input:<1> Output:<%d>\n", ft_atoi("1"));
|
||||
printf("Input:<14> Output:<%d>\n", ft_atoi("14"));
|
||||
printf("Input:<120> Output:<%d>\n", ft_atoi("120"));
|
||||
printf("Input:<-0> Output:<%d>\n", ft_atoi("-0"));
|
||||
printf("Input:<-1> Output:<%d>\n", ft_atoi("-1"));
|
||||
printf("Input:<-14> Output:<%d>\n", ft_atoi("-14"));
|
||||
printf("Input:<-120> Output:<%d>\n", ft_atoi("-120"));
|
||||
printf("Input:<2147483647> Output:<%d>\n", ft_atoi("2147483647"));
|
||||
printf("Input:<-2147483648> Output:<%d>\n", ft_atoi("-2147483648"));
|
||||
printf("Input:<--2147483648> Output:<%d>\n", ft_atoi("--2147483648"));
|
||||
printf("Input:<---2147483648> Output:<%d>\n", ft_atoi("---2147483648"));
|
||||
printf("Input:<----2147483648> Output:<%d>\n", ft_atoi("----2147483648"));
|
||||
printf("Input:<+-+14> Output:<%d>\n", ft_atoi("+-+14"));
|
||||
printf("Input:<-+-+14> Output:<%d>\n", ft_atoi("-+-+14"));
|
||||
printf("Input:<-+-14> Output:<%d>\n", ft_atoi("-+-14"));
|
||||
printf("Input:<+-+-14> Output:<%d>\n", ft_atoi("+-+-14"));
|
||||
printf("Input:< -14> Output:<%d>\n", ft_atoi(" -14"));
|
||||
printf("Input:< +-+14> Output:<%d>\n", ft_atoi(" +-+14"));
|
||||
printf("Input:< -+-+14> Output:<%d>\n", ft_atoi(" -+-+14"));
|
||||
printf("Input:< -+-14> Output:<%d>\n", ft_atoi(" -+-14"));
|
||||
printf("Input:< +-+-14> Output:<%d>\n", ft_atoi(" +-+-14"));
|
||||
printf("Input:< -14> Output:<%d>\n", ft_atoi(" -14"));
|
||||
printf("Input:< +-+14> Output:<%d>\n", ft_atoi(" +-+14"));
|
||||
printf("Input:< -+-+14> Output:<%d>\n", ft_atoi(" -+-+14"));
|
||||
printf("Input:< -+-14> Output:<%d>\n", ft_atoi(" -+-14"));
|
||||
printf("Input:< +-+-14> Output:<%d>\n", ft_atoi(" +-+-14"));
|
||||
printf("Input:<\t\t-14> Output:<%d>\n", ft_atoi("\t\t-14"));
|
||||
printf("Input:<\t\t+-+14> Output:<%d>\n", ft_atoi("\t\t+-+14"));
|
||||
printf("Input:<\t\t-+-+14> Output:<%d>\n", ft_atoi("\t\t-+-+14"));
|
||||
printf("Input:<\t\t-+-14> Output:<%d>\n", ft_atoi("\t\t-+-14"));
|
||||
printf("Input:<\t\t+-+-14> Output:<%d>\n", ft_atoi("\t\t+-+-14"));
|
||||
printf("Input:<\n\n-14> Output:<%d>\n", ft_atoi("\n\n-14"));
|
||||
printf("Input:<\n\n+-+14> Output:<%d>\n", ft_atoi("\n\n+-+14"));
|
||||
printf("Input:<\n\n-+-+14> Output:<%d>\n", ft_atoi("\n\n-+-+14"));
|
||||
printf("Input:<\n\n-+-14> Output:<%d>\n", ft_atoi("\n\n-+-14"));
|
||||
printf("Input:<\n\n+-+-14> Output:<%d>\n", ft_atoi("\n\n+-+-14"));
|
||||
printf("Input:<\n\n-14baba1> Output:<%d>\n", ft_atoi("\n\n-14baba1"));
|
||||
printf("Input:<\n\n+-+14baba1> Output:<%d>\n", ft_atoi("\n\n+-+14baba1"));
|
||||
printf("Input:<\n\n-+-+14baba1> Output:<%d>\n", ft_atoi("\n\n-+-+14baba1"));
|
||||
printf("Input:<\n\n-+-14baba1> Output:<%d>\n", ft_atoi("\n\n-+-14baba1"));
|
||||
printf("Input:<\n\n+-+-14baba1> Output:<%d>\n", ft_atoi("\n\n+-+-14baba1"));
|
||||
printf("Expected:<> Actual:<%d>\n", ft_atoi(""));
|
||||
printf("Expected:<0> Actual:<%d>\n", ft_atoi("0"));
|
||||
printf("Expected:<1> Actual:<%d>\n", ft_atoi("1"));
|
||||
printf("Expected:<14> Actual:<%d>\n", ft_atoi("14"));
|
||||
printf("Expected:<120> Actual:<%d>\n", ft_atoi("120"));
|
||||
printf("Expected:<-0> Actual:<%d>\n", ft_atoi("-0"));
|
||||
printf("Expected:<-1> Actual:<%d>\n", ft_atoi("-1"));
|
||||
printf("Expected:<-14> Actual:<%d>\n", ft_atoi("-14"));
|
||||
printf("Expected:<-120> Actual:<%d>\n", ft_atoi("-120"));
|
||||
printf("Expected:<2147483647> Actual:<%d>\n", ft_atoi("2147483647"));
|
||||
printf("Expected:<-2147483648> Actual:<%d>\n", ft_atoi("-2147483648"));
|
||||
printf("Expected:<--2147483648> Actual:<%d>\n", ft_atoi("--2147483648"));
|
||||
printf("Expected:<---2147483648> Actual:<%d>\n", ft_atoi("---2147483648"));
|
||||
printf("Expected:<----2147483648> Actual:<%d>\n", ft_atoi("----2147483648"));
|
||||
printf("Expected:<+-+14> Actual:<%d>\n", ft_atoi("+-+14"));
|
||||
printf("Expected:<-+-+14> Actual:<%d>\n", ft_atoi("-+-+14"));
|
||||
printf("Expected:<-+-14> Actual:<%d>\n", ft_atoi("-+-14"));
|
||||
printf("Expected:<+-+-14> Actual:<%d>\n", ft_atoi("+-+-14"));
|
||||
printf("Expected:< -14> Actual:<%d>\n", ft_atoi(" -14"));
|
||||
printf("Expected:< +-+14> Actual:<%d>\n", ft_atoi(" +-+14"));
|
||||
printf("Expected:< -+-+14> Actual:<%d>\n", ft_atoi(" -+-+14"));
|
||||
printf("Expected:< -+-14> Actual:<%d>\n", ft_atoi(" -+-14"));
|
||||
printf("Expected:< +-+-14> Actual:<%d>\n", ft_atoi(" +-+-14"));
|
||||
printf("Expected:< -14> Actual:<%d>\n", ft_atoi(" -14"));
|
||||
printf("Expected:< +-+14> Actual:<%d>\n", ft_atoi(" +-+14"));
|
||||
printf("Expected:< -+-+14> Actual:<%d>\n", ft_atoi(" -+-+14"));
|
||||
printf("Expected:< -+-14> Actual:<%d>\n", ft_atoi(" -+-14"));
|
||||
printf("Expected:< +-+-14> Actual:<%d>\n", ft_atoi(" +-+-14"));
|
||||
printf("Expected:<\t\t-14> Actual:<%d>\n", ft_atoi("\t\t-14"));
|
||||
printf("Expected:<\t\t+-+14> Actual:<%d>\n", ft_atoi("\t\t+-+14"));
|
||||
printf("Expected:<\t\t-+-+14> Actual:<%d>\n", ft_atoi("\t\t-+-+14"));
|
||||
printf("Expected:<\t\t-+-14> Actual:<%d>\n", ft_atoi("\t\t-+-14"));
|
||||
printf("Expected:<\t\t+-+-14> Actual:<%d>\n", ft_atoi("\t\t+-+-14"));
|
||||
printf("Expected:<\n\n-14> Actual:<%d>\n", ft_atoi("\n\n-14"));
|
||||
printf("Expected:<\n\n+-+14> Actual:<%d>\n", ft_atoi("\n\n+-+14"));
|
||||
printf("Expected:<\n\n-+-+14> Actual:<%d>\n", ft_atoi("\n\n-+-+14"));
|
||||
printf("Expected:<\n\n-+-14> Actual:<%d>\n", ft_atoi("\n\n-+-14"));
|
||||
printf("Expected:<\n\n+-+-14> Actual:<%d>\n", ft_atoi("\n\n+-+-14"));
|
||||
printf("Expected:<\n\n-14baba1> Actual:<%d>\n", ft_atoi("\n\n-14baba1"));
|
||||
printf("Expected:<\n\n+-+14baba1> Actual:<%d>\n", ft_atoi("\n\n+-+14baba1"));
|
||||
printf("Expected:<\n\n-+-+14baba1> Actual:<%d>\n", ft_atoi("\n\n-+-+14baba1"));
|
||||
printf("Expected:<\n\n-+-14baba1> Actual:<%d>\n", ft_atoi("\n\n-+-14baba1"));
|
||||
printf("Expected:<\n\n+-+-14baba1> Actual:<%d>\n", ft_atoi("\n\n+-+-14baba1"));
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,961 @@
|
|||
#include <stdio.h>
|
||||
#define BASEINVALID1 "01234567890"
|
||||
#define BASEINVALID2 "0123456789 "
|
||||
#define BASE10 "0123456789"
|
||||
#define BASE2 "01"
|
||||
#define BASE3 "012"
|
||||
#define BASE9 "012345678"
|
||||
#define BASE11 "0123456789a"
|
||||
#define BASE16 "0123456789abcdef"
|
||||
#define BASE90 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGH" \
|
||||
"IJKLMNOPQRSTUVWXYZ!#$%^&*()_=`~{}[]'|;,./<>?:\""
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *base;
|
||||
char *input;
|
||||
|
||||
base = BASEINVALID1;
|
||||
printf("Base: %s\n", base);
|
||||
input = "123";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASEINVALID2;
|
||||
printf("Base: %s\n", base);
|
||||
input = "123";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASE10;
|
||||
printf("Base: %s\n", base);
|
||||
input = "-2147483648";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2147483647";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2147483646";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "2147483647";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13ac";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13bc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13cc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASE2;
|
||||
printf("Base: %s\n", base);
|
||||
input = "-10000000000000000000000000000000";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1111111111111111111111111111111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1111111111111111111111111111110";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1100";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1011";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1010";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1001";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1000";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-110";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-100";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "100";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "110";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1000";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1001";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1010";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1011";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1100";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1111111111111111111111111111111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101ac";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101bc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 1101cc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-1101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASE3;
|
||||
printf("Base: %s\n", base);
|
||||
input = "-12112122212110202102";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-12112122212110202101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-12112122212110202100";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-110";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-102";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-100";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-22";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-21";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-20";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "20";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "21";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "22";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "100";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "102";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "110";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "12112122212110202101";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111ac";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111bc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 111cc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-111";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASE9;
|
||||
printf("Base: %s\n", base);
|
||||
input = "-5478773672";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-5478773671";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-5478773670";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-14";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "14";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "5478773671";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13ac";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13bc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 13cc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-13";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASE11;
|
||||
printf("Base: %s\n", base);
|
||||
input = "-a02220282";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-a02220281";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-a02220280";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "10";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "11";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "a02220281";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12y";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12y";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12y";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12yc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12yc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " 12yc";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-12";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASE16;
|
||||
printf("Base: %s\n", base);
|
||||
input = "-80000000";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-7fffffff";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-7ffffffe";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "7fffffff";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " dg";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " dg";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " dg";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " dgg";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " dgg";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " dgg";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
base = BASE90;
|
||||
printf("Base: %s\n", base);
|
||||
input = "-w%_DC";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-w%_DB";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-w%_DA";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "-1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "0";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "1";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "2";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "3";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "4";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "5";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "6";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "7";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "8";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "9";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "a";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "b";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "c";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = ":";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "\"";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = "w%_DB";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d+";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d+";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d+";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d+-";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d +";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " d+-";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " -+-+d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
input = " +-+-d";
|
||||
printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base));
|
||||
printf("\n");
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("-10: %d\n", ft_iterative_factorial(-10));
|
||||
printf("-1: %d\n", ft_iterative_factorial(-1));
|
||||
printf("0: %d\n", ft_iterative_factorial(0));
|
||||
printf("1: %d\n", ft_iterative_factorial(1));
|
||||
printf("2: %d\n", ft_iterative_factorial(2));
|
||||
printf("3: %d\n", ft_iterative_factorial(3));
|
||||
printf("4: %d\n", ft_iterative_factorial(4));
|
||||
printf("5: %d\n", ft_iterative_factorial(5));
|
||||
printf("10: %d\n", ft_iterative_factorial(10));
|
||||
printf("15: %d\n", ft_iterative_factorial(15));
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("-10: %d\n", ft_recursive_factorial(-10));
|
||||
printf("-1: %d\n", ft_recursive_factorial(-1));
|
||||
printf("0: %d\n", ft_recursive_factorial(0));
|
||||
printf("1: %d\n", ft_recursive_factorial(1));
|
||||
printf("2: %d\n", ft_recursive_factorial(2));
|
||||
printf("3: %d\n", ft_recursive_factorial(3));
|
||||
printf("4: %d\n", ft_recursive_factorial(4));
|
||||
printf("5: %d\n", ft_recursive_factorial(5));
|
||||
printf("10: %d\n", ft_recursive_factorial(10));
|
||||
printf("15: %d\n", ft_recursive_factorial(15));
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("base: <-3>, power <-2>, result: <%d>\n", ft_iterative_power(-3, -2));
|
||||
printf("base: <-2>, power <-2>, result: <%d>\n", ft_iterative_power(-2, -2));
|
||||
printf("base: <-1>, power <-2>, result: <%d>\n", ft_iterative_power(-1, -2));
|
||||
printf("base: <0>, power <-2>, result: <%d>\n", ft_iterative_power(0, -2));
|
||||
printf("base: <1>, power <-2>, result: <%d>\n", ft_iterative_power(1, -2));
|
||||
printf("base: <2>, power <-2>, result: <%d>\n", ft_iterative_power(2, -2));
|
||||
printf("base: <3>, power <-2>, result: <%d>\n", ft_iterative_power(3, -2));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <-1>, result: <%d>\n", ft_iterative_power(-3, -1));
|
||||
printf("base: <-2>, power <-1>, result: <%d>\n", ft_iterative_power(-2, -1));
|
||||
printf("base: <-1>, power <-1>, result: <%d>\n", ft_iterative_power(-1, -1));
|
||||
printf("base: <0>, power <-1>, result: <%d>\n", ft_iterative_power(0, -1));
|
||||
printf("base: <1>, power <-1>, result: <%d>\n", ft_iterative_power(1, -1));
|
||||
printf("base: <2>, power <-1>, result: <%d>\n", ft_iterative_power(2, -1));
|
||||
printf("base: <3>, power <-1>, result: <%d>\n", ft_iterative_power(3, -1));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power: <0>, result: <%d>\n", ft_iterative_power(-3, 0));
|
||||
printf("base: <-2>, power <0>, result: <%d>\n", ft_iterative_power(-2, 0));
|
||||
printf("base: <-1>, power <0>, result: <%d>\n", ft_iterative_power(-1, 0));
|
||||
printf("base: <0>, power <0>, result: <%d>\n", ft_iterative_power(0, 0));
|
||||
printf("base: <1>, power <0>, result: <%d>\n", ft_iterative_power(1, 0));
|
||||
printf("base: <2>, power <0>, result: <%d>\n", ft_iterative_power(2, 0));
|
||||
printf("base: <3>, power <0>, result: <%d>\n", ft_iterative_power(3, 0));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <1>, result: <%d>\n", ft_iterative_power(-3, 1));
|
||||
printf("base: <-2>, power <1>, result: <%d>\n", ft_iterative_power(-2, 1));
|
||||
printf("base: <-1>, power <1>, result: <%d>\n", ft_iterative_power(-1, 1));
|
||||
printf("base: <0>, power <1>, result: <%d>\n", ft_iterative_power(0, 1));
|
||||
printf("base: <1>, power <1>, result: <%d>\n", ft_iterative_power(1, 1));
|
||||
printf("base: <2>, power <1>, result: <%d>\n", ft_iterative_power(2, 1));
|
||||
printf("base: <3>, power <1>, result: <%d>\n", ft_iterative_power(3, 1));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <2>, result: <%d>\n", ft_iterative_power(-3, 2));
|
||||
printf("base: <-2>, power <2>, result: <%d>\n", ft_iterative_power(-2, 2));
|
||||
printf("base: <-1>, power <2>, result: <%d>\n", ft_iterative_power(-1, 2));
|
||||
printf("base: <0>, power <2>, result: <%d>\n", ft_iterative_power(0, 2));
|
||||
printf("base: <1>, power <2>, result: <%d>\n", ft_iterative_power(1, 2));
|
||||
printf("base: <2>, power <2>, result: <%d>\n", ft_iterative_power(2, 2));
|
||||
printf("base: <3>, power <2>, result: <%d>\n", ft_iterative_power(3, 2));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <3>, result: <%d>\n", ft_iterative_power(-3, 3));
|
||||
printf("base: <-2>, power <3>, result: <%d>\n", ft_iterative_power(-2, 3));
|
||||
printf("base: <-1>, power <3>, result: <%d>\n", ft_iterative_power(-1, 3));
|
||||
printf("base: <0>, power <3>, result: <%d>\n", ft_iterative_power(0, 3));
|
||||
printf("base: <1>, power <3>, result: <%d>\n", ft_iterative_power(1, 3));
|
||||
printf("base: <2>, power <3>, result: <%d>\n", ft_iterative_power(2, 3));
|
||||
printf("base: <3>, power <3>, result: <%d>\n", ft_iterative_power(3, 3));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <10>, result: <%d>\n", ft_iterative_power(-3, 10));
|
||||
printf("base: <-2>, power <10>, result: <%d>\n", ft_iterative_power(-2, 10));
|
||||
printf("base: <-1>, power <10>, result: <%d>\n", ft_iterative_power(-1, 10));
|
||||
printf("base: <0>, power <10>, result: <%d>\n", ft_iterative_power(0, 10));
|
||||
printf("base: <1>, power <10>, result: <%d>\n", ft_iterative_power(1, 10));
|
||||
printf("base: <2>, power <10>, result: <%d>\n", ft_iterative_power(2, 10));
|
||||
printf("base: <3>, power <10>, result: <%d>\n", ft_iterative_power(3, 10));
|
||||
printf("\n");
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("base: <-3>, power <-2>, result: <%d>\n", ft_recursive_power(-3, -2));
|
||||
printf("base: <-2>, power <-2>, result: <%d>\n", ft_recursive_power(-2, -2));
|
||||
printf("base: <-1>, power <-2>, result: <%d>\n", ft_recursive_power(-1, -2));
|
||||
printf("base: <0>, power <-2>, result: <%d>\n", ft_recursive_power(0, -2));
|
||||
printf("base: <1>, power <-2>, result: <%d>\n", ft_recursive_power(1, -2));
|
||||
printf("base: <2>, power <-2>, result: <%d>\n", ft_recursive_power(2, -2));
|
||||
printf("base: <3>, power <-2>, result: <%d>\n", ft_recursive_power(3, -2));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <-1>, result: <%d>\n", ft_recursive_power(-3, -1));
|
||||
printf("base: <-2>, power <-1>, result: <%d>\n", ft_recursive_power(-2, -1));
|
||||
printf("base: <-1>, power <-1>, result: <%d>\n", ft_recursive_power(-1, -1));
|
||||
printf("base: <0>, power <-1>, result: <%d>\n", ft_recursive_power(0, -1));
|
||||
printf("base: <1>, power <-1>, result: <%d>\n", ft_recursive_power(1, -1));
|
||||
printf("base: <2>, power <-1>, result: <%d>\n", ft_recursive_power(2, -1));
|
||||
printf("base: <3>, power <-1>, result: <%d>\n", ft_recursive_power(3, -1));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power: <0>, result: <%d>\n", ft_recursive_power(-3, 0));
|
||||
printf("base: <-2>, power <0>, result: <%d>\n", ft_recursive_power(-2, 0));
|
||||
printf("base: <-1>, power <0>, result: <%d>\n", ft_recursive_power(-1, 0));
|
||||
printf("base: <0>, power <0>, result: <%d>\n", ft_recursive_power(0, 0));
|
||||
printf("base: <1>, power <0>, result: <%d>\n", ft_recursive_power(1, 0));
|
||||
printf("base: <2>, power <0>, result: <%d>\n", ft_recursive_power(2, 0));
|
||||
printf("base: <3>, power <0>, result: <%d>\n", ft_recursive_power(3, 0));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <1>, result: <%d>\n", ft_recursive_power(-3, 1));
|
||||
printf("base: <-2>, power <1>, result: <%d>\n", ft_recursive_power(-2, 1));
|
||||
printf("base: <-1>, power <1>, result: <%d>\n", ft_recursive_power(-1, 1));
|
||||
printf("base: <0>, power <1>, result: <%d>\n", ft_recursive_power(0, 1));
|
||||
printf("base: <1>, power <1>, result: <%d>\n", ft_recursive_power(1, 1));
|
||||
printf("base: <2>, power <1>, result: <%d>\n", ft_recursive_power(2, 1));
|
||||
printf("base: <3>, power <1>, result: <%d>\n", ft_recursive_power(3, 1));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <2>, result: <%d>\n", ft_recursive_power(-3, 2));
|
||||
printf("base: <-2>, power <2>, result: <%d>\n", ft_recursive_power(-2, 2));
|
||||
printf("base: <-1>, power <2>, result: <%d>\n", ft_recursive_power(-1, 2));
|
||||
printf("base: <0>, power <2>, result: <%d>\n", ft_recursive_power(0, 2));
|
||||
printf("base: <1>, power <2>, result: <%d>\n", ft_recursive_power(1, 2));
|
||||
printf("base: <2>, power <2>, result: <%d>\n", ft_recursive_power(2, 2));
|
||||
printf("base: <3>, power <2>, result: <%d>\n", ft_recursive_power(3, 2));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <3>, result: <%d>\n", ft_recursive_power(-3, 3));
|
||||
printf("base: <-2>, power <3>, result: <%d>\n", ft_recursive_power(-2, 3));
|
||||
printf("base: <-1>, power <3>, result: <%d>\n", ft_recursive_power(-1, 3));
|
||||
printf("base: <0>, power <3>, result: <%d>\n", ft_recursive_power(0, 3));
|
||||
printf("base: <1>, power <3>, result: <%d>\n", ft_recursive_power(1, 3));
|
||||
printf("base: <2>, power <3>, result: <%d>\n", ft_recursive_power(2, 3));
|
||||
printf("base: <3>, power <3>, result: <%d>\n", ft_recursive_power(3, 3));
|
||||
printf("\n");
|
||||
|
||||
printf("base: <-3>, power <10>, result: <%d>\n", ft_recursive_power(-3, 10));
|
||||
printf("base: <-2>, power <10>, result: <%d>\n", ft_recursive_power(-2, 10));
|
||||
printf("base: <-1>, power <10>, result: <%d>\n", ft_recursive_power(-1, 10));
|
||||
printf("base: <0>, power <10>, result: <%d>\n", ft_recursive_power(0, 10));
|
||||
printf("base: <1>, power <10>, result: <%d>\n", ft_recursive_power(1, 10));
|
||||
printf("base: <2>, power <10>, result: <%d>\n", ft_recursive_power(2, 10));
|
||||
printf("base: <3>, power <10>, result: <%d>\n", ft_recursive_power(3, 10));
|
||||
printf("\n");
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#include <stdio.h>
|
||||
#define UNSIGNED_LONG_LONG_MAX_FIB 93
|
||||
#define INT_MAX_FIB 46
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = -12;
|
||||
while (++i <= INT_MAX_FIB + 1)
|
||||
printf("%d-th fib num: %d\n", i, ft_fibonacci(i));
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("%d, %d\n", 0, ft_sqrt(0));
|
||||
i = -20;
|
||||
while (++i <= 4000)
|
||||
if (ft_sqrt(i))
|
||||
printf("%d, %d\n", i, ft_sqrt(i));
|
||||
printf("%d, %d\n", INT_MIN, ft_sqrt(INT_MIN));
|
||||
printf("%d, %d\n", INT_MAX, ft_sqrt(INT_MAX));
|
||||
i = INT_MAX;
|
||||
while (--i > INT_MAX - 1000000)
|
||||
if (ft_sqrt(i))
|
||||
printf("%d, %d\n", i, ft_sqrt(i));
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
int prime_count;
|
||||
|
||||
prime_count = 0;
|
||||
i = -10;
|
||||
while (++i <= INT_MAX / 1000)
|
||||
{
|
||||
if (ft_is_prime(i))
|
||||
{
|
||||
// printf("Prime: %d\n", i);
|
||||
++prime_count;
|
||||
}
|
||||
}
|
||||
printf("Prime count up until %d: %d\n", INT_MAX / 1000, prime_count);
|
||||
return (0);
|
||||
}
|
||||
// first_primes[2] = 5;
|
||||
// sieve30[0] = 7;
|
||||
// sieve30[1] = 11;
|
||||
// sieve30[2] = 13;
|
||||
// sieve30[3] = 17;
|
||||
// sieve30[4] = 19;
|
||||
// sieve30[5] = 23;
|
||||
// sieve30[6] = 29;
|
||||
// sieve30[7] = 31;
|
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Given %d, next prime is %d\n", INT_MIN,
|
||||
ft_find_next_prime(INT_MIN));
|
||||
printf("Given %d, next prime is %d\n", -2, ft_find_next_prime(-2));
|
||||
printf("Given %d, next prime is %d\n", -1, ft_find_next_prime(-1));
|
||||
printf("Given %d, next prime is %d\n", 0, ft_find_next_prime(0));
|
||||
printf("Given %d, next prime is %d\n", 1, ft_find_next_prime(1));
|
||||
printf("Given %d, next prime is %d\n", 2, ft_find_next_prime(2));
|
||||
printf("Given %d, next prime is %d\n", 3, ft_find_next_prime(3));
|
||||
printf("Given %d, next prime is %d\n", 4, ft_find_next_prime(4));
|
||||
printf("Given %d, next prime is %d\n", 5, ft_find_next_prime(5));
|
||||
printf("Given %d, next prime is %d\n", 6, ft_find_next_prime(6));
|
||||
printf("Given %d, next prime is %d\n", 7, ft_find_next_prime(7));
|
||||
printf("Given %d, next prime is %d\n", 8, ft_find_next_prime(8));
|
||||
printf("Given %d, next prime is %d\n", 9, ft_find_next_prime(9));
|
||||
printf("Given %d, next prime is %d\n", 10, ft_find_next_prime(10));
|
||||
printf("Given %d, next prime is %d\n", 11, ft_find_next_prime(11));
|
||||
printf("Given %d, next prime is %d\n", 12, ft_find_next_prime(12));
|
||||
printf("Given %d, next prime is %d\n", INT_MAX - 1000,
|
||||
ft_find_next_prime(INT_MAX - 1000));
|
||||
printf("Given %d, next prime is %d\n", INT_MAX - 3,
|
||||
ft_find_next_prime(INT_MAX - 3));
|
||||
printf("Given %d, next prime is %d\n", INT_MAX - 2,
|
||||
ft_find_next_prime(INT_MAX - 2));
|
||||
printf("Given %d, next prime is %d\n", INT_MAX - 1,
|
||||
ft_find_next_prime(INT_MAX - 1));
|
||||
printf("Given %d, next prime is %d\n", INT_MAX,
|
||||
ft_find_next_prime(INT_MAX));
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("%d\n", ft_ten_queens_puzzle());
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *str1;
|
||||
char *stra;
|
||||
char *strb;
|
||||
char *str2;
|
||||
char *str3;
|
||||
char *str4;
|
||||
char *str_std1;
|
||||
char *str_stda;
|
||||
char *str_stdb;
|
||||
char *str_std2;
|
||||
char *str_std3;
|
||||
char *str_std4;
|
||||
|
||||
printf("### Testing ft_strdup ###\n");
|
||||
str1 = "The String";
|
||||
stra = "The String";
|
||||
strb = str1;
|
||||
str2 = ft_strdup(str1);
|
||||
str3 = ft_strdup(str1);
|
||||
str4 = ft_strdup(str2);
|
||||
printf("str1 value: %s, str1 address: %p\n", str1, str1);
|
||||
printf("stra value: %s, stra address: %p (==str1)\n", stra, stra);
|
||||
printf("strb value: %s, strb address: %p (==str1)\n", strb, strb);
|
||||
printf("str2 value: %s, str2 address: %p (diff)\n", str2, str2);
|
||||
printf("str3 value: %s, str3 address: %p (diff)\n", str3, str3);
|
||||
printf("str4 value: %s, str4 address: %p (diff)\n", str4, str4);
|
||||
free(str2);
|
||||
free(str3);
|
||||
free(str4);
|
||||
printf("\n### Testing strdup ###\n");
|
||||
str_std1 = "The Standard String";
|
||||
str_stda = "The Standard String";
|
||||
str_stdb = str_std1;
|
||||
str_std2 = strdup(str_std1);
|
||||
str_std3 = strdup(str_std1);
|
||||
str_std4 = strdup(str_std2);
|
||||
printf("str_std1 value: %s, str_std1 address: %p\n",
|
||||
str_std1, str_std1);
|
||||
printf("str_stda value: %s, str_stda address: %p (==str_std1)\n",
|
||||
str_stda, str_stda);
|
||||
printf("str_stdb value: %s, str_stdb address: %p (==str_std1)\n",
|
||||
str_stdb, str_stdb);
|
||||
printf("str_std2 value: %s, str_std2 address: %p (diff)\n",
|
||||
str_std2, str_std2);
|
||||
printf("str_std3 value: %s, str_std3 address: %p (diff)\n",
|
||||
str_std3, str_std3);
|
||||
printf("str_std4 value: %s, str_std4 address: %p (diff)\n",
|
||||
str_std4, str_std4);
|
||||
free(str_std2);
|
||||
free(str_std3);
|
||||
free(str_std4);
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int *arr;
|
||||
|
||||
k = -1;
|
||||
while (++k < 5)
|
||||
{
|
||||
i = -1;
|
||||
while (++i < 6)
|
||||
{
|
||||
arr = ft_range(k, i);
|
||||
printf("Range from k:%d to i:%d, ptr: %p: <", k, i, arr);
|
||||
j = -1;
|
||||
while (++j < i - k)
|
||||
{
|
||||
if (j < i - k - 1)
|
||||
printf("%d, ", arr[j]);
|
||||
else
|
||||
printf("%d", arr[j]);
|
||||
}
|
||||
printf(">\n");
|
||||
free(arr);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int idx;
|
||||
int min;
|
||||
int max;
|
||||
int *arr;
|
||||
int size;
|
||||
|
||||
min = -1;
|
||||
while (++min < 5)
|
||||
{
|
||||
max = -1;
|
||||
while (++max < 6)
|
||||
{
|
||||
size = ft_ultimate_range(&arr, min, max);
|
||||
printf("Range (size: %d) from min:%d to max:%d, ptr: %p: <",
|
||||
size, min, max, arr);
|
||||
idx = -1;
|
||||
while (++idx < max - min)
|
||||
{
|
||||
if (idx < max - min - 1)
|
||||
printf("%d, ", arr[idx]);
|
||||
else
|
||||
printf("%d", arr[idx]);
|
||||
}
|
||||
printf(">\n");
|
||||
if (arr != NULL)
|
||||
free(arr);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char **strs;
|
||||
char *sep;
|
||||
int size;
|
||||
char *result;
|
||||
|
||||
size = 5;
|
||||
// sep = "<DELIM>";
|
||||
sep = "";
|
||||
strs = malloc(sizeof(char*) * size);
|
||||
strs[0] = "First";
|
||||
strs[1] = "Second";
|
||||
strs[2] = "Third";
|
||||
strs[3] = "Fourth";
|
||||
strs[4] = "Fifth";
|
||||
printf("strs size: '%d'\n", size);
|
||||
printf("The delim: '%s'\n", sep);
|
||||
printf("strs[0]: '%s'\n", strs[0]);
|
||||
printf("strs[1]: '%s'\n", strs[1]);
|
||||
printf("strs[2]: '%s'\n", strs[2]);
|
||||
printf("strs[3]: '%s'\n", strs[3]);
|
||||
printf("strs[4]: '%s'\n", strs[4]);
|
||||
result = ft_strjoin(size, strs, sep);
|
||||
printf("The concatenated string: '%s'\n", result);
|
||||
printf("Length of that string: %d\n", ft_strlen(result));
|
||||
free(result);
|
||||
free(strs);
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,313 @@
|
|||
#include <stdio.h>
|
||||
#define INVALID_BASE_1 "01234567890"
|
||||
#define INVALID_BASE_2 "010"
|
||||
#define INVALID_BASE_3 "0123456789 "
|
||||
#define INVALID_BASE_4 "01 "
|
||||
|
||||
#define BASE10 "0123456789"
|
||||
#define BASE2 "01"
|
||||
#define BASE16 "0123456789abcdef"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *from_base;
|
||||
char *to_base;
|
||||
char *output;
|
||||
char *nbr;
|
||||
|
||||
from_base = BASE10;
|
||||
to_base = BASE10;
|
||||
printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base);
|
||||
nbr = "-2147483648";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-2147483647";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "0";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "3";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "4";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "5";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "2147483647";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
printf("\n");
|
||||
|
||||
from_base = BASE10;
|
||||
to_base = BASE2;
|
||||
printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base);
|
||||
nbr = "-2147483648";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-2147483647";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "0";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "3";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "4";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "5";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "2147483647";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
printf("\n");
|
||||
|
||||
from_base = BASE2;
|
||||
to_base = BASE10;
|
||||
printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base);
|
||||
nbr = "-10000000000000000000000000000000";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1111111111111111111111111111111";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-10";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "0";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "10";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "11";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "100";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "101";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1111111111111111111111111111111";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
printf("\n");
|
||||
|
||||
from_base = BASE2;
|
||||
to_base = BASE16;
|
||||
printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base);
|
||||
nbr = "-10000000000000000000000000000000";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1111111111111111111111111111111";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-10";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "0";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "10";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "11";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "100";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "101";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1111111111111111111111111111111";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
printf("\n");
|
||||
|
||||
from_base = BASE16;
|
||||
to_base = BASE2;
|
||||
printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base);
|
||||
nbr = "-80000000";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-7fffffff";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "0";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "3";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "4";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "5";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "7fffffff";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
printf("\n");
|
||||
|
||||
from_base = BASE10;
|
||||
to_base = BASE16;
|
||||
printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base);
|
||||
nbr = "-2147483648";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-2147483647";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "-1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "0";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "1";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "2";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "3";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "4";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "5";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
nbr = "2147483647";
|
||||
output = ft_convert_base(nbr, from_base, to_base);
|
||||
printf("Input: <%s>, Output: <%s>\n", nbr, output);
|
||||
free(output);
|
||||
printf("\n");
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
write(1, "<", 1);
|
||||
while (*str)
|
||||
write(1, str++, 1);
|
||||
write(1, ">", 1);
|
||||
}
|
||||
|
||||
// strs must be a null terminated array
|
||||
void ft_print_str_tab(char **strs, char *delim)
|
||||
{
|
||||
while (*strs)
|
||||
{
|
||||
ft_putstr(*strs++);
|
||||
ft_putstr(delim);
|
||||
}
|
||||
}
|
||||
|
||||
void free_tab(char **tab)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = -1;
|
||||
while (tab[++i])
|
||||
free(tab[i]);
|
||||
free(tab);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char **tab;
|
||||
|
||||
tab = ft_split(";0123:4567;89xx;1;1;1;1;1y2;", ":y;");
|
||||
ft_print_str_tab(tab, "\n");
|
||||
free_tab(tab);
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *strs[4];
|
||||
t_stock_str *tab;
|
||||
|
||||
strs[0] = "First";
|
||||
strs[1] = "Second";
|
||||
strs[2] = "Third";
|
||||
tab = ft_strs_to_tab(3, strs);
|
||||
printf("tab[0] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n",
|
||||
tab[0].size, tab[0].str, tab[0].str, tab[0].copy, tab[0].copy);
|
||||
printf("tab[1] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n",
|
||||
tab[1].size, tab[1].str, tab[1].str, tab[1].copy, tab[1].copy);
|
||||
printf("tab[2] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n",
|
||||
tab[2].size, tab[2].str, tab[2].str, tab[2].copy, tab[2].copy);
|
||||
printf("tab[3] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n",
|
||||
tab[3].size, tab[3].str, tab[3].str, tab[3].copy, tab[3].copy);
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include "../ex04/ft_strs_to_tab.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *strs[4];
|
||||
t_stock_str *tab;
|
||||
|
||||
strs[0] = "First";
|
||||
strs[1] = "Second";
|
||||
strs[2] = "Third";
|
||||
tab = ft_strs_to_tab(3, strs);
|
||||
ft_show_tab(tab);
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb > 9)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putchar(nb % 10 + '0');
|
||||
}
|
||||
else if (nb == INT_MIN)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putnbr(-(nb % 10));
|
||||
}
|
||||
else if (nb < 0)
|
||||
{
|
||||
ft_putchar('-');
|
||||
ft_putnbr(-nb);
|
||||
}
|
||||
else
|
||||
ft_putchar(nb % 10 + '0');
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ints[10] = {1, 2, 0, INT_MIN, 10, -1, 5, 0, 7, INT_MAX};
|
||||
ft_foreach(ints, 10, &ft_putnbr);
|
||||
return (0);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
int inc(int n)
|
||||
{
|
||||
return (n + 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ints[10] = {1, 2, 0, INT_MIN, 10, -1, 5, 0, 7, INT_MAX};
|
||||
int *ints2;
|
||||
|
||||
ints2 = ft_map(ints, 10, &inc);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
printf("%d\n", ints2[i]);
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue