42_C_PISCINE/Rush/Rush01/input.c

40 lines
655 B
C
Raw Permalink Normal View History

2023-05-17 12:45:25 -04:00
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
int ft_input(char *str)
{
int i;
int counter;
int *tab;
i = 0;
counter = 1;
while (str[i] != 0)
{
if ('0' < str[i] && str[i] < '5')
counter++;
else
if (str[i] != ' ')
return (0);
i++;
}
i = 0;
tab = malloc(sizeof(tab) * counter);
counter = 0;
while (str[i] != 0)
{
if ('0' < str[i] && str[i] < '5')
{
tab[counter] = str[i] - '0';
counter++;
}
i++;
}
}