ft_sort_params
#include <unistd.h>
int ft_strcmp(char *s1, char *s2)
{
while ((*s1 == *s2) && (*s1 != '\\0'))
{
s1++;
s2++;
}
return (*s1 - *s2);
}
void ft_put_str(char *str)
{
int i;
i = 0;
while (str[i] != '\\0')
{
write(1, &str[i], 1);
i++;
}
write(1, "\\n", 1);
}
void sort(char **s1, int size)
{
int i;
int j;
char *temp;
i = 1;
while (i < size -1)
{
j = 0;
while (j + 1 < size)
{
if (ft_strcmp(s1[j], s1[j + 1]) > 0)
{
temp = s1[j];
s1[j] = s1[j + 1];
s1[j + 1] = temp;
}
j++;
}
i++;
}
}
int main(int argc, char **argv)
{
int i;
i = 1;
sort(argv, argc);
while (i < argc)
{
ft_put_str(argv[i]);
i++;
}
}
기계채점을 받았는데 KO가 떴다. 왜 그런지 궁금해서 찾아보니 파라미터 값이 “”일 경우에 개행 문자가 출력이 되지 않았다.