#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
void strcpy(char *str, char *nombre)
{
int i;
int j;
i = 0;
j = 0;
while (str[i] != '\0')
{
if (str[i] >= '0' && str[i] <= '9')
{
nombre[j] = str[i];
j++;
}
i++;
}
nombre[j] = '\0';
solver(nombre);
}
int ft_test(char *str)
{
int i;
int neg;
i = 0;
neg = 0;
while (str[i] != '\0' && str[i] < '0' || str[i] == '\t' || str[i] == '\n'
|| str[i] == '\r' || str[i] == '\v' || str[i] == '\f' || str[i] == ' ')
{
if (str[i] == '-')
neg++;
i++;
}
while (str[i] != '\0' && str[i] >= '0' && str[i] <= '9')
{
nombre[j] = str[i];
i++;
j++;
}
if (neg % 2 == 1)
write(1, "Error\n", 77);
else
{
return (0);
}
return (1);
}
int main(int argc, char **argv)
{
char nombre;
if (argc == 2)
if (ft_test(argv[1]) == 0)
strcpy(argv[1], &nombre);
if (argc == 3)
{
if (ft_test(argv[2]) == 0)
strcpy(argv[2], &nombre);
}
return (0);
}
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
}
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
{
i++;
}
return (i);
}
int ft_atoi(char *str)
{
int c;
int s;
int res;
c = 0;
s = 1;
res = 0;
while (str[c] && ((str[c] >= 9 && str[c] <= 13) || str[c] == 32))
c++;
while (str[c] && (str[c] == '+' || str[c] == '-'))
{
if (str[c] == '-')
s *= -1;
c++;
}
while (str[c] && (str[c] >= '0' && str[c] <= '9'))
{
res = (str[c] - '0') + (res * 10);
c++;
}
return (res * s);
}
char *ft_strcat(char *dest, char *src)
{
int i;
int n;
i = 0;
n = 0;
while (dest[n])
{
n++;
}
while (src[i])
{
dest[n + i] = src[i];
i++;
}
dest[n + i] = '\0';
return (dest);
}
char *ft_strdup(char *src)
{
int i;
int len;
char *dst;
len = 0;
while (src[len])
len++;
dst = (char *)malloc(sizeof(char) * (len + 1));
if (!dst)
return (0);
i = 0;
while (i < len)
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
return (dst);
}
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
void ft_putstr(char *str);
void ft_test(char *str);
void solver( char *str)
{
write(1, "le nombre a ecrire est:\n", 23);
ft_putstr(*nombre);
write(1, "\n", 1);
write(1, "J'peux pas j'ai piscine!\n", 25);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: