resolu pbm ac %.i ou 0i
This commit is contained in:
@@ -52,7 +52,7 @@ char *ft_convert(va_list ap, char *type, char **s);
|
||||
char *precision_int(char *print, int precision);
|
||||
char *ft_precision(char *s, char *print, char *type);
|
||||
char *width_flags(char *print, char *s, int width, int zero);
|
||||
char *ft_width(char *s, char *print, int *size);
|
||||
char *ft_width(char *s, char *print, int *size, char *type);
|
||||
char *ft_flag_transform(char *s, char *print, char *type, int *size);
|
||||
|
||||
#endif
|
||||
|
||||
246
main.c
246
main.c
@@ -524,26 +524,26 @@ int main(int ac, char **av)
|
||||
printf("----------------------------------------------------------------\n\n");
|
||||
}
|
||||
|
||||
// if (ac == 2 || !strcmp(av[2], "repetition"))
|
||||
// {
|
||||
// printf("\n----------------------------------------------------------------\n");
|
||||
// printf("tests repetitions of flags [0-]\n");
|
||||
// printf("----------------------------------------------------------------\n\n");
|
||||
if (ac == 2 || !strcmp(av[2], "repetition"))
|
||||
{
|
||||
printf("\n----------------------------------------------------------------\n");
|
||||
printf("tests repetitions of flags [0-]\n");
|
||||
printf("----------------------------------------------------------------\n\n");
|
||||
|
||||
// PRINT("%i", 33333);
|
||||
// PRINT("%08i", 33333);
|
||||
// PRINT("%-8i", 33333);
|
||||
PRINT("%i", 33333);
|
||||
PRINT("%08i", 33333);
|
||||
PRINT("%-8i", 33333);
|
||||
|
||||
// printf("\nrepetition of flag '0' -----------------------------------------\n");
|
||||
// printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
printf("\nrepetition of flag '0' -----------------------------------------\n");
|
||||
printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
|
||||
// PRINT("%0000i", 33333);
|
||||
PRINT("%0000i", 33333);
|
||||
|
||||
// printf("\nrepetition of flag '-' -----------------------------------------\n");
|
||||
// printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
printf("\nrepetition of flag '-' -----------------------------------------\n");
|
||||
printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
|
||||
// PRINT("%----i", 33333);
|
||||
// }
|
||||
PRINT("%----i", 33333);
|
||||
}
|
||||
}
|
||||
|
||||
if (ac >= 2 && ac <= 3 && !strcmp(av[1], "bonus"))
|
||||
@@ -652,127 +652,127 @@ int main(int ac, char **av)
|
||||
printf("----------------------------------------------------------------\n\n");
|
||||
}
|
||||
|
||||
// if (ac == 2 || !strcmp(av[2], "repetition"))
|
||||
// {
|
||||
// printf("\n----------------------------------------------------------------\n");
|
||||
// printf("tests repetitions of flags [0-#' +]\n");
|
||||
// printf("----------------------------------------------------------------\n\n");
|
||||
if (ac == 2 || !strcmp(av[2], "repetition"))
|
||||
{
|
||||
printf("\n----------------------------------------------------------------\n");
|
||||
printf("tests repetitions of flags [0-#' +]\n");
|
||||
printf("----------------------------------------------------------------\n\n");
|
||||
|
||||
// PRINT("%i", 33333);
|
||||
// PRINT("%.0f", 33333.0);
|
||||
// PRINT("%#.0f", 33333.0);
|
||||
// PRINT("%08i", 33333);
|
||||
// PRINT("%-8i", 33333);
|
||||
// PRINT("%+i", 33333);
|
||||
// PRINT("% i", 33333);
|
||||
// PRINT("%'i", 33333);
|
||||
PRINT("%i", 33333);
|
||||
PRINT("%.0f", 33333.0);
|
||||
PRINT("%#.0f", 33333.0);
|
||||
PRINT("%08i", 33333);
|
||||
PRINT("%-8i", 33333);
|
||||
PRINT("%+i", 33333);
|
||||
PRINT("% i", 33333);
|
||||
PRINT("%'i", 33333);
|
||||
|
||||
// printf("\nrepetition of flag '0' -----------------------------------------\n");
|
||||
// printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
printf("\nrepetition of flag '0' -----------------------------------------\n");
|
||||
printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
|
||||
// PRINT("%0000i", 33333);
|
||||
// PRINT("%0#.0f", 33333.0);
|
||||
// PRINT("%#0.0f", 33333.0);
|
||||
// PRINT("%0#0.0f", 33333.0);
|
||||
// PRINT("%0+8i", 33333);
|
||||
// PRINT("%+08i", 33333);
|
||||
// PRINT("%0+08i", 33333);
|
||||
// PRINT("%0 i", 33333);
|
||||
// PRINT("% 0i", 33333);
|
||||
// PRINT("%0 0i", 33333);
|
||||
// PRINT("%0'i", 33333);
|
||||
// PRINT("%'0i", 33333);
|
||||
// PRINT("%0'0i", 33333);
|
||||
PRINT("%0000i", 33333);
|
||||
PRINT("%0#.0f", 33333.0);
|
||||
PRINT("%#0.0f", 33333.0);
|
||||
PRINT("%0#0.0f", 33333.0);
|
||||
PRINT("%0+8i", 33333);
|
||||
PRINT("%+08i", 33333);
|
||||
PRINT("%0+08i", 33333);
|
||||
PRINT("%0 i", 33333);
|
||||
PRINT("% 0i", 33333);
|
||||
PRINT("%0 0i", 33333);
|
||||
PRINT("%0'i", 33333);
|
||||
PRINT("%'0i", 33333);
|
||||
PRINT("%0'0i", 33333);
|
||||
|
||||
// printf("\nrepetition of flag '-' -----------------------------------------\n");
|
||||
// printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
printf("\nrepetition of flag '-' -----------------------------------------\n");
|
||||
printf("'0' and '-' not compatible -------------------------------------\n\n");
|
||||
|
||||
// PRINT("%----i", 33333);
|
||||
// PRINT("%-#.0f", 33333.0);
|
||||
// PRINT("%#-.0f", 33333.0);
|
||||
// PRINT("%-#-.0f", 33333.0);
|
||||
// PRINT("%-+8i", 33333);
|
||||
// PRINT("%+-8i", 33333);
|
||||
// PRINT("%-+-8i", 33333);
|
||||
// PRINT("%- i", 33333);
|
||||
// PRINT("% -i", 33333);
|
||||
// PRINT("%- -i", 33333);
|
||||
// PRINT("%-'i", 33333);
|
||||
// PRINT("%'-i", 33333);
|
||||
// PRINT("%-'-i", 33333);
|
||||
PRINT("%----i", 33333);
|
||||
PRINT("%-#.0f", 33333.0);
|
||||
PRINT("%#-.0f", 33333.0);
|
||||
PRINT("%-#-.0f", 33333.0);
|
||||
PRINT("%-+8i", 33333);
|
||||
PRINT("%+-8i", 33333);
|
||||
PRINT("%-+-8i", 33333);
|
||||
PRINT("%- i", 33333);
|
||||
PRINT("% -i", 33333);
|
||||
PRINT("%- -i", 33333);
|
||||
PRINT("%-'i", 33333);
|
||||
PRINT("%'-i", 33333);
|
||||
PRINT("%-'-i", 33333);
|
||||
|
||||
// printf("\nrepetition of flag '#' -----------------------------------------\n");
|
||||
printf("\nrepetition of flag '#' -----------------------------------------\n");
|
||||
|
||||
// PRINT("%####f", 33333.0);
|
||||
// PRINT("%#+.0f", 33333.0);
|
||||
// PRINT("%+#.0f", 33333.0);
|
||||
// PRINT("%#+#.0f", 33333.0);
|
||||
// PRINT("%#08f", 33333.0);
|
||||
// PRINT("%0#8f", 33333.0);
|
||||
// PRINT("%#0#8f", 33333.0);
|
||||
// PRINT("%#-8f", 33333.0);
|
||||
// PRINT("%-#8f", 33333.0);
|
||||
// PRINT("%#-#8f", 33333.0);
|
||||
// PRINT("%#'f", 33333.0);
|
||||
// PRINT("%'#f", 33333.0);
|
||||
// PRINT("%#'#f", 33333.0);
|
||||
// PRINT("%# f", 33333.0);
|
||||
// PRINT("% #f", 33333.0);
|
||||
// PRINT("%# #f", 33333.0);
|
||||
PRINT("%####f", 33333.0);
|
||||
PRINT("%#+.0f", 33333.0);
|
||||
PRINT("%+#.0f", 33333.0);
|
||||
PRINT("%#+#.0f", 33333.0);
|
||||
PRINT("%#08f", 33333.0);
|
||||
PRINT("%0#8f", 33333.0);
|
||||
PRINT("%#0#8f", 33333.0);
|
||||
PRINT("%#-8f", 33333.0);
|
||||
PRINT("%-#8f", 33333.0);
|
||||
PRINT("%#-#8f", 33333.0);
|
||||
PRINT("%#'f", 33333.0);
|
||||
PRINT("%'#f", 33333.0);
|
||||
PRINT("%#'#f", 33333.0);
|
||||
PRINT("%# f", 33333.0);
|
||||
PRINT("% #f", 33333.0);
|
||||
PRINT("%# #f", 33333.0);
|
||||
|
||||
// printf("\nrepetition of flag ''' -----------------------------------------\n\n");
|
||||
printf("\nrepetition of flag ''' -----------------------------------------\n\n");
|
||||
|
||||
// PRINT("%''''i", 33333);
|
||||
// PRINT("%'#.0f", 33333.0);
|
||||
// PRINT("%#'.0f", 33333.0);
|
||||
// PRINT("%'#'.0f", 33333.0);
|
||||
// PRINT("%'08i", 33333);
|
||||
// PRINT("%0'8i", 33333);
|
||||
// PRINT("%'0'8i", 33333);
|
||||
// PRINT("%'-8i", 33333);
|
||||
// PRINT("%-'8i", 33333);
|
||||
// PRINT("%'-'8i", 33333);
|
||||
// PRINT("%'+i", 33333);
|
||||
// PRINT("%+'i", 33333);
|
||||
// PRINT("%'+'i", 33333);
|
||||
// PRINT("%' i", 33333);
|
||||
// PRINT("% 'i", 33333);
|
||||
// PRINT("%' 'i", 33333);
|
||||
PRINT("%''''i", 33333);
|
||||
PRINT("%'#.0f", 33333.0);
|
||||
PRINT("%#'.0f", 33333.0);
|
||||
PRINT("%'#'.0f", 33333.0);
|
||||
PRINT("%'08i", 33333);
|
||||
PRINT("%0'8i", 33333);
|
||||
PRINT("%'0'8i", 33333);
|
||||
PRINT("%'-8i", 33333);
|
||||
PRINT("%-'8i", 33333);
|
||||
PRINT("%'-'8i", 33333);
|
||||
PRINT("%'+i", 33333);
|
||||
PRINT("%+'i", 33333);
|
||||
PRINT("%'+'i", 33333);
|
||||
PRINT("%' i", 33333);
|
||||
PRINT("% 'i", 33333);
|
||||
PRINT("%' 'i", 33333);
|
||||
|
||||
// printf("\nrepetition of flag ' ' -----------------------------------------\n");
|
||||
// printf("'+' and ' ' not compatible -------------------------------------\n\n");
|
||||
printf("\nrepetition of flag ' ' -----------------------------------------\n");
|
||||
printf("'+' and ' ' not compatible -------------------------------------\n\n");
|
||||
|
||||
// PRINT("% i", 33333);
|
||||
// PRINT("% #.0f", 33333.0);
|
||||
// PRINT("%# .0f", 33333.0);
|
||||
// PRINT("% # .0f", 33333.0);
|
||||
// PRINT("% 08i", 33333);
|
||||
// PRINT("%0 8i", 33333);
|
||||
// PRINT("% 0 8i", 33333);
|
||||
// PRINT("% -8i", 33333);
|
||||
// PRINT("%- 8i", 33333);
|
||||
// PRINT("% - 8i", 33333);
|
||||
// PRINT("% 'i", 33333);
|
||||
// PRINT("%' i", 33333);
|
||||
// PRINT("% ' i", 33333);
|
||||
PRINT("% i", 33333);
|
||||
PRINT("% #.0f", 33333.0);
|
||||
PRINT("%# .0f", 33333.0);
|
||||
PRINT("% # .0f", 33333.0);
|
||||
PRINT("% 08i", 33333);
|
||||
PRINT("%0 8i", 33333);
|
||||
PRINT("% 0 8i", 33333);
|
||||
PRINT("% -8i", 33333);
|
||||
PRINT("%- 8i", 33333);
|
||||
PRINT("% - 8i", 33333);
|
||||
PRINT("% 'i", 33333);
|
||||
PRINT("%' i", 33333);
|
||||
PRINT("% ' i", 33333);
|
||||
|
||||
// printf("\nrepetition of flag '+' -----------------------------------------\n");
|
||||
// printf("'+' and ' ' not compatible -------------------------------------\n\n");
|
||||
printf("\nrepetition of flag '+' -----------------------------------------\n");
|
||||
printf("'+' and ' ' not compatible -------------------------------------\n\n");
|
||||
|
||||
// PRINT("%++++i", 33333);
|
||||
// PRINT("%+#.0f", 33333.0);
|
||||
// PRINT("%#+.0f", 33333.0);
|
||||
// PRINT("%+#+.0f", 33333.0);
|
||||
// PRINT("%+08i", 33333);
|
||||
// PRINT("%0+8i", 33333);
|
||||
// PRINT("%+0+8i", 33333);
|
||||
// PRINT("%+-8i", 33333);
|
||||
// PRINT("%-+8i", 33333);
|
||||
// PRINT("%+-+8i", 33333);
|
||||
// PRINT("%+'i", 33333);
|
||||
// PRINT("%'+i", 33333);
|
||||
// PRINT("%+'+i", 33333);
|
||||
// }
|
||||
PRINT("%++++i", 33333);
|
||||
PRINT("%+#.0f", 33333.0);
|
||||
PRINT("%#+.0f", 33333.0);
|
||||
PRINT("%+#+.0f", 33333.0);
|
||||
PRINT("%+08i", 33333);
|
||||
PRINT("%0+8i", 33333);
|
||||
PRINT("%+0+8i", 33333);
|
||||
PRINT("%+-8i", 33333);
|
||||
PRINT("%-+8i", 33333);
|
||||
PRINT("%+-+8i", 33333);
|
||||
PRINT("%+'i", 33333);
|
||||
PRINT("%'+i", 33333);
|
||||
PRINT("%+'+i", 33333);
|
||||
}
|
||||
}
|
||||
|
||||
if (ac == 2 && !strcmp(av[1], "error"))
|
||||
|
||||
@@ -142,14 +142,14 @@ char *width_flags(char *print, char *s, int width, int zero)
|
||||
** 4 otherwise 'size' is the length of print + zero
|
||||
*/
|
||||
|
||||
char *ft_width(char *s, char *print, int *size)
|
||||
char *ft_width(char *s, char *print, int *size, char *type)
|
||||
{
|
||||
char *tmp;
|
||||
int zero;
|
||||
|
||||
tmp = s;
|
||||
zero = 0;
|
||||
if (print[0] == '\0')
|
||||
if (print[0] == '\0' && ft_strchr(type, 'c'))
|
||||
zero = 1;
|
||||
while (*tmp != '\0' && ft_strchr("%#- +'0.", *tmp))
|
||||
tmp++;
|
||||
@@ -175,7 +175,7 @@ char *ft_width(char *s, char *print, int *size)
|
||||
char *ft_flag_transform(char *s, char *print, char *type, int *size)
|
||||
{
|
||||
print = ft_precision(s, print, type);
|
||||
print = ft_width(s, print, size);
|
||||
print = ft_width(s, print, size, type);
|
||||
if (ft_strchr(type, 'p'))
|
||||
{
|
||||
print = ft_concat_free(ft_strdup("0x"), print);
|
||||
|
||||
Reference in New Issue
Block a user