tests flag p

This commit is contained in:
hugodu69
2020-06-24 17:33:33 +02:00
parent 97e809a3fc
commit a1b21caa35
4 changed files with 18 additions and 10 deletions

20
main.c
View File

@@ -816,15 +816,21 @@ int main(int ac, char **av)
printf("----------------------------------------------------------------\n\n");
char *s;
PRINT("%p", "test")
PRINT("%p", s)
PRINT("%p", "test");
PRINT("%p", s);
s = "truc";
PRINT("%p", s)
PRINT("%p", s);
unsigned int u = 4;
PRINT("%p", &u)
PRINT("%s-%p", s, s)
PRINT("%u-%p", u, &u)
PRINT("%up", u)
PRINT("%p", &u);
PRINT("%s-%p", s, s);
PRINT("%u-%p", u, &u);
PRINT("%up", u);
PRINT("%p", NULL);
PRINT("%5p", NULL);
PRINT("%05p", NULL);
PRINT("%0p", NULL);
PRINT("%5.p", NULL);
PRINT("%5.5p", NULL);
}
if (ac == 2 || !strcmp(av[2], "%"))

1
outf.txt Normal file
View File

@@ -0,0 +1 @@
(nil)

1
outft.txt Normal file
View File

@@ -0,0 +1 @@
0x0

View File

@@ -188,13 +188,13 @@ char *ft_flag_transform(char *s, char *print, char *type, int *size)
print = ft_precision(s, print, type);
print = ft_plus(s, print, type);
print = ft_sharp(s, print, type);
print = ft_width(s, print, size, type);
print = ft_sharp_again(s, print, type);
print = ft_space(s, print, type, size);
if (ft_strchr(type, 'p'))
{
print = ft_concat_free(ft_strdup("0x"), print);
*size += 2;
}
print = ft_width(s, print, size, type);
print = ft_sharp_again(s, print, type);
print = ft_space(s, print, type, size);
return (print);
}