majdsaadat / quaqamolee

0 stars 0 forks source link

c06 #20

Open majdsaadat opened 4 months ago

majdsaadat commented 4 months ago

/* ** / / / / ::: :::::::: / / ft_print_program_name.c :+: :+: :+: / / +:+ +:+ +:+ / / By: msaadat marvin@42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2024/07/01 13:24:26 by msaadat #+# #+# / / Updated: 2024/07/01 13:25:03 by msaadat ### ########.fr / / / / ** */

include

include

void p(char c) { write(1, &c, 1); }

int main(int argc, char *argv[]) { int i;

i = 0;
if (argc > 0)
{
    while (argv[0][i] != '\0')
    {
        p(argv[0][i]);
        i++;
    }
}
write (1, "\n", 1);
return (0);

}

majdsaadat commented 4 months ago

/* ** / / / / ::: :::::::: / / ft_print_params.c :+: :+: :+: / / +:+ +:+ +:+ / / By: msaadat marvin@42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2024/07/01 13:26:40 by msaadat #+# #+# / / Updated: 2024/07/01 13:27:04 by msaadat ### ########.fr / / / / ** */

include

include

void print(char c) { write(1, &c, 1); }

int main(int argc, char **argv) { int i; int j;

i = 1;
if (argc > 1)
{
    while (i < argc)
    {
        j = 0;
        while (argv[i][j] != '\0')
        {
            print(argv[i][j]);
            j++;
        }
        i++;
        write(1, "\n", 1);
    }
}
return (0);

}

majdsaadat commented 4 months ago

/* ** / / / / ::: :::::::: / / ft_rev_params.c :+: :+: :+: / / +:+ +:+ +:+ / / By: msaadat marvin@42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2024/07/01 13:28:26 by msaadat #+# #+# / / Updated: 2024/07/01 13:29:19 by msaadat ### ########.fr / / / / ** */

include

include

void print(char ch) { write(1, &ch, 1); }

int main(int argc, char **argv) { int i; int j;

i = argc - 1;
while (i > 0)
{
    j = 0;
    while (argv[i][j] != '\0')
    {
        print(argv[i][j]);
        j++;
    }
    i--;
    print('\n');
}
return (0);

}

majdsaadat commented 4 months ago

/* ** / / / / ::: :::::::: / / ft_sort_params.c :+: :+: :+: / / +:+ +:+ +:+ / / By: msaadat marvin@42.fr +#+ +:+ +#+ / / +#+#+#+#+#+ +#+ / / Created: 2024/07/01 13:29:58 by msaadat #+# #+# / / Updated: 2024/07/01 13:30:21 by msaadat ### ########.fr / / / / ** */

include

void ft_putchar(char c) { write(1, &c, 1); }

int ft_strcmp(char str1, char str2) { int i;

i = 0;
while (str1[i] == str2[i] && str1[i] != '\0')
    i++;
return (str1[i] - str2[i]);

}

void ft_print_args(int argc, char **argv) { int i; int j;

i = 1;
while (i < argc)
{
    j = 0;
    while (argv[i][j] != '\0')
    {
        ft_putchar(argv[i][j]);
        j++;
    }
    i++;
    ft_putchar('\n');
}

}

int main(int argc, char *argv) { int i; int j; char arg;

i = 1;
while (i < argc)
{
    j = i;
    while (ft_strcmp(argv[j], argv[j - 1]) < 0 && j > 1)
    {
        arg = argv[j - 1];
        argv[j - 1] = argv[j];
        argv[j] = arg;
        j--;
    }
    i++;
}
ft_print_args(argc, argv);
return (0);

}