0
0
This commit is contained in:
2021-08-24 20:55:48 +02:00
parent 175220f3f6
commit c629a99412
6 changed files with 39 additions and 38 deletions

View File

@@ -28,19 +28,22 @@ static char *ft_strncpy(char *dest, char *src, unsigned int n)
dest[i] = '\0';
i++;
}
dest[i] = '\0';
return (dest);
}
static int ft_is_charset(char c, char *charset)
{
char *p_charset;
int r;
int i;
r = 0;
p_charset = charset;
while (*p_charset != '\0')
r |= (*p_charset++ == c);
return (r);
i = 0;
while (charset[i] != '\0')
{
if (c == charset[i])
return (1);
i++;
}
return (0);
}
static int ft_split_len(char *str, char *charset)

View File

@@ -17,17 +17,20 @@
char **ft_split(char *str, char *charset);
int main(void)
int main(int argc, char *argv[])
{
char str[32];
char charset[32];
char *str;
char *charset;
char **strs;
int i;
printf("Input String [Max 32]: ");
scanf("%s", str);
printf("Input Charset [Max 32]: ");
scanf("%s", charset);
if (argc < 2)
{
printf("%s <str> <charset>\n", argv[0]);
return (1);
}
str = argv[1];
charset = argv[2];
strs = ft_split(str, charset);
printf("str=%s charset=%s (ft_split)\n", str, charset);
i = 0;

View File

@@ -5,5 +5,5 @@ rm -f a.out
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
./a.out "$@"
rm -f a.out