This commit is contained in:
parent
2f121d0be1
commit
0f615a0cf8
|
@ -0,0 +1,29 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
printf("Expected:%c\nActual:", 'a');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('a');
|
||||||
|
printf("\nExpected:%c\nActual:", 'b');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('b');
|
||||||
|
printf("\nExpected:%c\nActual:", 'c');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('c');
|
||||||
|
printf("\nExpected:%c\nActual:", 'd');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('d');
|
||||||
|
printf("\nExpected:%c\nActual:", '@');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('@');
|
||||||
|
printf("\nExpected:%c\nActual:", '~');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('~');
|
||||||
|
printf("\nExpected:%c\nActual:", ' ');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar(' ');
|
||||||
|
printf("\n");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
ft_putstr("Hello World\n");
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#define STR1 "hellb"
|
||||||
|
#define STR2 "hello"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
printf("'%s' VS '%s'\n", STR1, STR2);
|
||||||
|
result = ft_strcmp(STR1, STR2);
|
||||||
|
if(!result)
|
||||||
|
printf("Strings are the same (0)\n");
|
||||||
|
else
|
||||||
|
printf("Strings are different (offset=%d)\n", result);
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
printf("%d\n", ft_strlen("HELLO WORLD"));
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
|
||||||
|
a = 1;
|
||||||
|
b = 2;
|
||||||
|
printf("%d, %d\n", a, b);
|
||||||
|
ft_swap(&a, &b);
|
||||||
|
printf("%d, %d\n", a, b);
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
printf("Expected:%c\nActual:", 'a');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('a');
|
||||||
|
printf("\nExpected:%c\nActual:", 'b');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('b');
|
||||||
|
printf("\nExpected:%c\nActual:", 'c');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('c');
|
||||||
|
printf("\nExpected:%c\nActual:", 'd');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('d');
|
||||||
|
printf("\nExpected:%c\nActual:", '@');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('@');
|
||||||
|
printf("\nExpected:%c\nActual:", '~');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar('~');
|
||||||
|
printf("\nExpected:%c\nActual:", ' ');
|
||||||
|
fflush(stdout);
|
||||||
|
ft_putchar(' ');
|
||||||
|
printf("\n");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
ft_putstr("Hello World\n");
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#define STR1 "hellb"
|
||||||
|
#define STR2 "hello"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
printf("'%s' VS '%s'\n", STR1, STR2);
|
||||||
|
result = ft_strcmp(STR1, STR2);
|
||||||
|
if(!result)
|
||||||
|
printf("Strings are the same (0)\n");
|
||||||
|
else
|
||||||
|
printf("Strings are different (offset=%d)\n", result);
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
printf("%d\n", ft_strlen("HELLO WORLD"));
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
|
||||||
|
a = 1;
|
||||||
|
b = 2;
|
||||||
|
printf("%d, %d\n", a, b);
|
||||||
|
ft_swap(&a, &b);
|
||||||
|
printf("%d, %d\n", a, b);
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void ft_putstr(char *str)
|
||||||
|
{
|
||||||
|
write(1, "<", 1);
|
||||||
|
while (*str)
|
||||||
|
write(1, str++, 1);
|
||||||
|
write(1, ">", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// strs must be a null terminated array
|
||||||
|
void ft_print_str_tab(char **strs, char *delim)
|
||||||
|
{
|
||||||
|
while (*strs)
|
||||||
|
{
|
||||||
|
ft_putstr(*strs++);
|
||||||
|
ft_putstr(delim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_tab(char **tab)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
while (tab[++i])
|
||||||
|
free(tab[i]);
|
||||||
|
free(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
char **tab;
|
||||||
|
|
||||||
|
tab = ft_split(";0123:4567;89xx;1;1;1;1;1y2;", ":y;");
|
||||||
|
ft_print_str_tab(tab, "\n");
|
||||||
|
free_tab(tab);
|
||||||
|
return (0);
|
||||||
|
}
|
Loading…
Reference in New Issue