40 lines
655 B
C
40 lines
655 B
C
|
#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++;
|
||
|
}
|
||
|
}
|