/*
This code tests for legal number bases, used in the ft_putnbr_base program.
*/
int legal_base_check(char *base)
{
int i;
int j;
i = 0;
// base zero rejection
if (base[0] == '\0' || base[1] == '\0')
return (0);
while (base[i]) // loops over the base string
{
j = 0;
while (base[j])
{
if (i!= j && base[i] == base[j])
return (0);
j++;
}
if (base[i] == '+' || base[i] == '-')
return (0);
if (base[i] < 32 || base[i] > 126)
return (0);
i++;
}
return (1);
}
#include <stdio.h>
int main() {
char base[] = "qwertyuiop";
printf("base %s : %d\n", base, legal_base_check(base));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: