├── shell00 ├── ex00 │ └── z ├── ex04 │ └── midLS ├── ex09 │ └── ft_magic ├── ex05 │ └── git_commit.sh ├── ex06 │ └── git_ignore.sh ├── ex08 │ └── clean ├── ex03 │ └── id_rsa_pub ├── ex07 │ └── b ├── ex01 │ └── testShell00.tar └── ex02 │ └── exo2.tar ├── C02 ├── ex09 │ └── ft_strcapitalize.c ├── ex00 │ └── ft_strcpy.c ├── ex07 │ └── ft_strupcase.c ├── ex08 │ └── ft_strlowcase.c ├── ex03 │ └── ft_str_is_numeric.c ├── ex05 │ └── ft_str_is_uppercase.c ├── ex06 │ └── ft_str_is_printable.c ├── ex04 │ └── ft_str_is_lowercase.c ├── ex01 │ └── ft_strncpy.c └── ex02 │ └── ft_str_is_alpha.c ├── shell01 ├── ex05 │ └── "\?$*'MaRViN'*$?\" ├── ex06 │ └── skip.sh ├── ex03 │ └── count_files.sh ├── ex04 │ └── MAC.sh ├── ex01 │ └── print_groups.sh └── ex02 │ └── find_sh.sh ├── Exam00 ├── ft_add.c ├── only_a.c ├── ft_subtract.c ├── hello.c ├── ft_countdown.c ├── occ_a.c ├── count_alen.c ├── ft_print_numbers.c ├── maff_revalpha.c ├── ft_odd.c ├── ft_swap.c ├── maff_alpha.c ├── ft_strcmp.c ├── ft_interval.c ├── ft_strrev.c └── ft_atoi.c ├── Exam01 ├── ft_add.c ├── only_z.c ├── ft_subtract.c ├── occ_a.c ├── count_alen.c ├── ft_strlen.c ├── ft_swap.c ├── ft_odd.c ├── first_word.c ├── interval_space.c ├── rev_print.c ├── ft_count_words.c ├── ft_interval.c ├── sum_even_position.c ├── ft_strrev.c ├── rotone.c ├── wdmatch.c ├── rot_13.c ├── last_word.c ├── inter.c ├── union.c └── ft_range.c ├── Exam02 ├── ft_add.c ├── ft_subtract.c ├── aff_z.c ├── occ_a.c ├── count_alen.c ├── ft_strlen.c ├── ft_odd.c ├── ft_swap.c ├── aff_a.c ├── first_word.c ├── interval_space.c ├── rev_print.c ├── rotone.c ├── ft_count_words.c ├── ft_interval.c ├── sum_even_position.c ├── ft_strrev.c ├── rot_13.c ├── last_word.c ├── wdmatch.c ├── ft_atoi.c ├── inter.c ├── union.c ├── title.c ├── ft_range.c ├── ft_rrange.c └── ft_split.c ├── Final-Exam ├── ft_add.c ├── ft_subtract.c ├── aff_z.c ├── occ_a.c ├── count_alen.c ├── ft_print_numbers.c ├── aff_last_param.c ├── ft_odd.c ├── ft_strcpy.c ├── interval_space.c ├── ulstr.c ├── rev_print.c ├── ft_count_words.c ├── ft_interval.c ├── sum_even_position.c ├── ft_strrev.c ├── rle.c ├── fizzbuzz.c ├── ft_atoi.c ├── union.c ├── title.c ├── ft_range.c ├── ft_rrange.c ├── nth_char.c └── ft_split.c ├── C09 ├── ex00 │ ├── libft_creator.sh │ ├── ft_putchar.c │ ├── ft_swap.c │ ├── ft_strlen.c │ ├── ft_putstr.c │ └── ft_strcmp.c ├── ex01 │ └── Makefile └── ex02 │ └── ft_split.c ├── C01 ├── ex00 │ └── ft_ft.c ├── ex01 │ └── ft_ultimate_ft.c ├── ex03 │ └── ft_div_mod.c ├── ex02 │ └── ft_swap.c ├── ex06 │ └── ft_strlen.c ├── ex04 │ └── ft_ultimate_div_mod.c ├── ex05 │ └── ft_putstr.c ├── ex07 │ └── ft_rev_int_tab.c └── ex08 │ └── ft_sort_int_tab.c ├── C00 ├── ex00 │ └── ft_putchar.c ├── ex04 │ └── ft_is_negative.c ├── ex03 │ └── ft_print_numbers.c ├── ex01 │ └── ft_print_alphabet.c ├── ex02 │ └── ft_print_reverse_alphabet.c ├── ex05 │ └── ft_print_comb.c ├── ex07 │ └── ft_putnbr.c └── ex06 │ └── ft_print_comb2.c ├── rush00 ├── ft_putchar.c ├── main.c └── rush00.c ├── C08 ├── ex02 │ └── ft_abs.h ├── ex03 │ └── ft_point.h ├── ex00 │ └── ft.h ├── ex04 │ ├── ft_stock_str.h │ └── ft_strs_to_tab.c ├── ex05 │ ├── ft_stock_str.h │ └── ft_show_tab.c └── ex01 │ └── ft_boolean.h ├── C04 ├── ex00 │ └── ft_strlen.c ├── ex01 │ └── ft_putstr.c ├── ex02 │ └── ft_putnbr.c ├── ex03 │ └── ft_atoi.c └── ex04 │ └── ft_putnbr_base.c ├── C03 ├── ex00 │ └── ft_strcmp.c ├── ex01 │ └── ft_strncmp.c ├── ex02 │ └── ft_strcat.c ├── ex03 │ └── ft_strncat.c ├── ex04 │ └── ft_strstr.c └── ex05 │ └── ft_strlcat.c ├── C05 ├── ex01 │ └── ft_recursive_factorial.c ├── ex06 │ └── ft_is_prime.c ├── ex00 │ └── ft_iterative_factorial.c ├── ex03 │ └── ft_recursive_power.c ├── ex04 │ └── ft_fibonacci.c ├── ex05 │ └── ft_sqrt.c ├── ex02 │ └── ft_iterative_power.c └── ex07 │ └── ft_find_next_prime.c ├── C06 ├── ex00 │ └── ft_print_program_name.c ├── ex01 │ └── ft_print_params.c ├── ex02 │ └── ft_rev_params.c └── ex03 │ └── ft_sort_params.c ├── C07 ├── ex01 │ └── ft_range.c ├── ex00 │ └── ft_strdup.c ├── ex02 │ └── ft_ultimate_range.c └── ex03 │ └── ft_strjoin.c └── README.md /shell00/ex00/z: -------------------------------------------------------------------------------- 1 | Z 2 | -------------------------------------------------------------------------------- /C02/ex09/ft_strcapitalize.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shell00/ex04/midLS: -------------------------------------------------------------------------------- 1 | ls -mtp 2 | -------------------------------------------------------------------------------- /shell01/ex05/"\?$*'MaRViN'*$?\": -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /shell00/ex09/ft_magic: -------------------------------------------------------------------------------- 1 | 41 string 42 42 file 2 | -------------------------------------------------------------------------------- /shell01/ex06/skip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -l | awk 'NR % 2 == 1' 3 | -------------------------------------------------------------------------------- /shell00/ex05/git_commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git log -n 5 --format='%H' 3 | -------------------------------------------------------------------------------- /shell01/ex03/count_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . | wc -l | sed 's/ //g' 3 | -------------------------------------------------------------------------------- /Exam00/ft_add.c: -------------------------------------------------------------------------------- 1 | void ft_add(int a,int *ptr) 2 | { 3 | *ptr = *ptr + a; 4 | } 5 | -------------------------------------------------------------------------------- /Exam01/ft_add.c: -------------------------------------------------------------------------------- 1 | void ft_add(int a,int *ptr) 2 | { 3 | *ptr = *ptr + a; 4 | } 5 | -------------------------------------------------------------------------------- /Exam02/ft_add.c: -------------------------------------------------------------------------------- 1 | void ft_add(int a,int *ptr) 2 | { 3 | *ptr = *ptr + a; 4 | } 5 | -------------------------------------------------------------------------------- /shell00/ex06/git_ignore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git ls-files -o -i --exclude-standard 3 | -------------------------------------------------------------------------------- /shell00/ex08/clean: -------------------------------------------------------------------------------- 1 | find .. -type f \( -name "#*#" -o -name "*~" \) -print -delete 2 | -------------------------------------------------------------------------------- /shell01/ex04/MAC.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ifconfig | grep "ether " | awk '{print $2}' 3 | -------------------------------------------------------------------------------- /Exam00/only_a.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | write(1,"a",1); 5 | } 6 | -------------------------------------------------------------------------------- /Exam01/only_z.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | write(1,"z",1); 5 | } 6 | -------------------------------------------------------------------------------- /Final-Exam/ft_add.c: -------------------------------------------------------------------------------- 1 | void ft_add(int a,int *ptr) 2 | { 3 | *ptr = *ptr + a; 4 | } 5 | -------------------------------------------------------------------------------- /shell01/ex01/print_groups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | id -Gn $FT_USER | tr ' ' ',' | tr -d '\n' 3 | -------------------------------------------------------------------------------- /Exam00/ft_subtract.c: -------------------------------------------------------------------------------- 1 | void ft_subtract(int a, int *ptr) 2 | { 3 | *ptr = *ptr - a; 4 | } 5 | -------------------------------------------------------------------------------- /Exam01/ft_subtract.c: -------------------------------------------------------------------------------- 1 | void ft_subtract(int a, int *ptr) 2 | { 3 | *ptr = *ptr - a; 4 | } 5 | -------------------------------------------------------------------------------- /Exam02/ft_subtract.c: -------------------------------------------------------------------------------- 1 | void ft_subtract(int a, int *ptr) 2 | { 3 | *ptr = *ptr - a; 4 | } 5 | -------------------------------------------------------------------------------- /shell01/ex02/find_sh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f -name "*.sh" -exec basename {} .sh \; 3 | -------------------------------------------------------------------------------- /Final-Exam/ft_subtract.c: -------------------------------------------------------------------------------- 1 | void ft_subtract(int a, int *ptr) 2 | { 3 | *ptr = *ptr - a; 4 | } 5 | -------------------------------------------------------------------------------- /Exam00/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | write(1, "Hello World!\n",14); 5 | } 6 | -------------------------------------------------------------------------------- /Exam02/aff_z.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | write(1,"z\n",2); 7 | }else 8 | write(1,"z\n",2); 9 | } 10 | -------------------------------------------------------------------------------- /Final-Exam/aff_z.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac , char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | write(1,"z\n",2); 7 | }else 8 | write(1,"z\n",2); 9 | } 10 | -------------------------------------------------------------------------------- /Exam00/ft_countdown.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char c = '9'; 5 | while (c >= '0') 6 | { 7 | write(1,&c,1); 8 | c--; 9 | } 10 | write(1,"\n",1); 11 | } 12 | -------------------------------------------------------------------------------- /C09/ex00/libft_creator.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | cc -c -Wall -Wextra -Werror ft_putchar.c ft_swap.c ft_putstr.c ft_strlen.c ft_strcmp.c 3 | ar rcs libft.a ft_putchar.o ft_swap.o ft_putstr.o ft_strlen.o ft_strcmp.o 4 | -------------------------------------------------------------------------------- /Exam00/occ_a.c: -------------------------------------------------------------------------------- 1 | int occ_a(char *str) 2 | { 3 | int count = 0; 4 | while(*str != '\0') 5 | { 6 | if(*str == 'A') 7 | { 8 | count++; 9 | } 10 | str++; 11 | } 12 | return (count); 13 | } 14 | -------------------------------------------------------------------------------- /Exam01/occ_a.c: -------------------------------------------------------------------------------- 1 | int occ_a(char *str) 2 | { 3 | int count = 0; 4 | while(*str != '\0') 5 | { 6 | if(*str == 'A') 7 | { 8 | count++; 9 | } 10 | str++; 11 | } 12 | return (count); 13 | } 14 | -------------------------------------------------------------------------------- /Exam02/occ_a.c: -------------------------------------------------------------------------------- 1 | int occ_a(char *str) 2 | { 3 | int count = 0; 4 | while(*str != '\0') 5 | { 6 | if(*str == 'A') 7 | { 8 | count++; 9 | } 10 | str++; 11 | } 12 | return (count); 13 | } 14 | -------------------------------------------------------------------------------- /Exam00/count_alen.c: -------------------------------------------------------------------------------- 1 | int ft_count_alen(char *str) 2 | { 3 | int i = 0; 4 | while(str[i] != '\0') 5 | { 6 | if(str[i] == 'a') 7 | { 8 | return(i); 9 | } 10 | i++; 11 | } 12 | return(i); 13 | } 14 | -------------------------------------------------------------------------------- /Exam01/count_alen.c: -------------------------------------------------------------------------------- 1 | int ft_count_alen(char *str) 2 | { 3 | int i = 0; 4 | while(str[i] != '\0') 5 | { 6 | if(str[i] == 'a') 7 | { 8 | return(i); 9 | } 10 | i++; 11 | } 12 | return(i); 13 | } 14 | -------------------------------------------------------------------------------- /Exam02/count_alen.c: -------------------------------------------------------------------------------- 1 | int ft_count_alen(char *str) 2 | { 3 | int i = 0; 4 | while(str[i] != '\0') 5 | { 6 | if(str[i] == 'a') 7 | { 8 | return(i); 9 | } 10 | i++; 11 | } 12 | return(i); 13 | } 14 | -------------------------------------------------------------------------------- /Final-Exam/occ_a.c: -------------------------------------------------------------------------------- 1 | int occ_a(char *str) 2 | { 3 | int count = 0; 4 | while(*str != '\0') 5 | { 6 | if(*str == 'A') 7 | { 8 | count++; 9 | } 10 | str++; 11 | } 12 | return (count); 13 | } 14 | -------------------------------------------------------------------------------- /Final-Exam/count_alen.c: -------------------------------------------------------------------------------- 1 | int ft_count_alen(char *str) 2 | { 3 | int i = 0; 4 | while(str[i] != '\0') 5 | { 6 | if(str[i] == 'a') 7 | { 8 | return(i); 9 | } 10 | i++; 11 | } 12 | return(i); 13 | } 14 | -------------------------------------------------------------------------------- /Exam00/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | void ft_print_numbers(void) 3 | { 4 | char c = '0'; 5 | while( c <= '9') 6 | { 7 | write(1,&c,1); 8 | c++; 9 | } 10 | } 11 | int main() 12 | { 13 | ft_print_numbers(); 14 | } 15 | -------------------------------------------------------------------------------- /Exam02/ft_strlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return i; 8 | } 9 | int main() 10 | { 11 | char str[] = "ostouayr"; 12 | printf("%d\n",ft_strlen(str)); 13 | } 14 | -------------------------------------------------------------------------------- /Exam01/ft_strlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while (str[i] != '\0') 6 | i++; 7 | return(i); 8 | } 9 | int main() 10 | { 11 | char str[] = "boxee"; 12 | printf("%d\n",ft_strlen(str)); 13 | } 14 | -------------------------------------------------------------------------------- /Exam01/ft_swap.c: -------------------------------------------------------------------------------- 1 | #include 2 | void ft_swap(int *a, int *b) 3 | { 4 | int temp = *a;*a = *b;*b = temp; 5 | } 6 | int main() 7 | { 8 | int a = 6; 9 | int b = 7; 10 | ft_swap(&a,&b); 11 | printf("a is :%d b is: %d\n",a,b); 12 | } 13 | -------------------------------------------------------------------------------- /Final-Exam/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | void ft_print_numbers(void) 3 | { 4 | char i = '0'; 5 | while(i <= '9') 6 | { 7 | write(1,&i,sizeof(i)); 8 | i++; 9 | } 10 | } 11 | int main(void) 12 | { 13 | ft_print_numbers(); 14 | } 15 | -------------------------------------------------------------------------------- /Final-Exam/aff_last_param.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac > 1) 5 | { 6 | int i = ac -1; 7 | int j = 0; 8 | while(av[i][j] != '\0') 9 | { 10 | write(1,&av[i][j],1); 11 | j++; 12 | } 13 | } 14 | write(1,"\n",1); 15 | } 16 | -------------------------------------------------------------------------------- /Exam00/maff_revalpha.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char i = 'z'; 5 | while(i >= 'a') 6 | { 7 | if(i % 2 == 1) 8 | { 9 | i -=32; 10 | write(1,&i,1); 11 | i += 32; 12 | }else 13 | write(1,&i,1); 14 | i--; 15 | } 16 | write(1,"\n",1); 17 | } 18 | -------------------------------------------------------------------------------- /Exam00/ft_odd.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av ) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while (av[1][i] != '\0') 8 | { 9 | if(i % 2 == 1) 10 | { 11 | write(1, &av[1][i], 1); 12 | } 13 | i++; 14 | } 15 | } 16 | write(1, "\n", 1); 17 | } 18 | -------------------------------------------------------------------------------- /Exam01/ft_odd.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av ) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while (av[1][i] != '\0') 8 | { 9 | if(i % 2 == 1) 10 | { 11 | write(1, &av[1][i], 1); 12 | } 13 | i++; 14 | } 15 | } 16 | write(1, "\n", 1); 17 | } 18 | -------------------------------------------------------------------------------- /Exam02/ft_odd.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av ) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while (av[1][i] != '\0') 8 | { 9 | if(i % 2 == 1) 10 | { 11 | write(1, &av[1][i], 1); 12 | } 13 | i++; 14 | } 15 | } 16 | write(1, "\n", 1); 17 | } 18 | -------------------------------------------------------------------------------- /Exam02/ft_swap.c: -------------------------------------------------------------------------------- 1 | #include 2 | void ft_swap(int *a, int *b) 3 | { 4 | int temp = *a;*a = *b;*b = temp; 5 | } 6 | int main() 7 | { 8 | int a = 5; 9 | int b = 10; 10 | printf("now a is :%d b is : %d\n",a,b); 11 | ft_swap(&a,&b); 12 | printf("now a is: %d b is : %d\n",a,b); 13 | } 14 | -------------------------------------------------------------------------------- /Final-Exam/ft_odd.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av ) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while (av[1][i] != '\0') 8 | { 9 | if(i % 2 == 1) 10 | { 11 | write(1, &av[1][i], 1); 12 | } 13 | i++; 14 | } 15 | } 16 | write(1, "\n", 1); 17 | } 18 | -------------------------------------------------------------------------------- /Exam00/ft_swap.c: -------------------------------------------------------------------------------- 1 | #include 2 | void ft_swap(int *a, int *b) 3 | { 4 | int temp = *a; 5 | *a = *b; 6 | *b = temp; 7 | } 8 | int main() 9 | { 10 | int a = 10; 11 | int b = 2; 12 | printf("a is : %d b is : %d\n",a,b); 13 | ft_swap(&a,&b); 14 | printf("a is : %d b is : %d\n",a,b); 15 | } 16 | -------------------------------------------------------------------------------- /Exam00/maff_alpha.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char i = 'a'; 5 | while(i <= 'z') 6 | { 7 | if(i % 2 == 0) 8 | { 9 | i -=32; 10 | write(1,&i,1); 11 | i += 32; 12 | 13 | }else 14 | { 15 | write(1,&i,1); 16 | } 17 | i++; 18 | } 19 | write(1, "\n",1); 20 | } 21 | -------------------------------------------------------------------------------- /Exam02/aff_a.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i] != '\0') 8 | { 9 | if(av[1][i] == 'a') 10 | { 11 | write(1,"a",1); 12 | break; 13 | } 14 | i++; 15 | } 16 | write(1,"\n",1); 17 | }else 18 | write(1, "a\n",2); 19 | } 20 | -------------------------------------------------------------------------------- /Exam00/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strcmp(char *s1, char *s2) 3 | { 4 | int i = 0; 5 | while(s1[i] == s2[i] && s1[i] != '\0'&& s2[i] != '\0') 6 | { 7 | i++; 8 | } 9 | return(s1[i] - s2[i]); 10 | } 11 | int main() 12 | { 13 | char s1[] = "Ou"; 14 | char s2[] = "Oj"; 15 | printf("%d",ft_strcmp(s1,s2)); 16 | } 17 | -------------------------------------------------------------------------------- /Exam01/first_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i] == ' ' || av[1][i] == '\t') 8 | i++; 9 | while(av[1][i] != '\0' && av[1][i] != '\t' && av[1][i] != ' ') 10 | { 11 | write(1,&av[1][i],1); 12 | i++; 13 | } 14 | } 15 | write(1,"\n",1); 16 | } 17 | -------------------------------------------------------------------------------- /Exam02/first_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i] == ' ' || av[1][i] == '\t') 8 | i++; 9 | while(av[1][i] != '\0' && (av[1][i] != ' ' && av[1][i] != '\t')) 10 | { 11 | write(1,&av[1][i],1); 12 | i++; 13 | } 14 | } 15 | write(1,"\n",1); 16 | } 17 | -------------------------------------------------------------------------------- /Final-Exam/ft_strcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | char *ft_strcpy(char *s1, char *s2) 3 | { 4 | int i = 0; 5 | while(s2[i] != '\0') 6 | { 7 | s1[i] = s2[i]; 8 | i++; 9 | } 10 | s1[i] = '\0'; 11 | return(s1); 12 | } 13 | int main(void) 14 | { 15 | char s1[] = ""; 16 | char s2[] = "boxee99"; 17 | ft_strcpy(s1,s2); 18 | printf("s2 is:%s and s1 is:%s\n",s2,s1); 19 | } 20 | -------------------------------------------------------------------------------- /Exam01/interval_space.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i]) 8 | { 9 | if(av[1][i] != '\0') 10 | { 11 | write(1, &av[1][i], 1); 12 | if(av[1][i + 1] == '\0') 13 | { 14 | break; 15 | } 16 | write(1, " ", 3); 17 | } 18 | i++; 19 | } 20 | } 21 | write(1, "\n", 1); 22 | } 23 | -------------------------------------------------------------------------------- /Exam02/interval_space.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i]) 8 | { 9 | if(av[1][i] != '\0') 10 | { 11 | write(1, &av[1][i], 1); 12 | if(av[1][i + 1] == '\0') 13 | { 14 | break; 15 | } 16 | write(1, " ", 3); 17 | } 18 | i++; 19 | } 20 | } 21 | write(1, "\n", 1); 22 | } 23 | -------------------------------------------------------------------------------- /Exam02/rev_print.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return i; 8 | } 9 | char *ft_rev_print (char *str) 10 | { 11 | int j = ft_strlen(str); 12 | while(j) 13 | { 14 | write(1,&str[j - 1],1); 15 | j--; 16 | } 17 | write(1,"\n",1); 18 | return(str); 19 | } 20 | int main() 21 | { 22 | ft_rev_print("Ossama"); 23 | } 24 | -------------------------------------------------------------------------------- /Final-Exam/interval_space.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i]) 8 | { 9 | if(av[1][i] != '\0') 10 | { 11 | write(1, &av[1][i], 1); 12 | if(av[1][i + 1] == '\0') 13 | { 14 | break; 15 | } 16 | write(1, " ", 3); 17 | } 18 | i++; 19 | } 20 | } 21 | write(1, "\n", 1); 22 | } 23 | -------------------------------------------------------------------------------- /Final-Exam/ulstr.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i] != '\0') 8 | { 9 | if(av[1][i] >= 'a' && av[1][i] <= 'z') 10 | { 11 | av[1][i] -= 32; 12 | }else if(av[1][i] >= 'A' && av[1][i] <= 'Z') 13 | { 14 | av[1][i] += 32; 15 | } 16 | write(1,&av[1][i],1); 17 | i++; 18 | } 19 | } 20 | write(1,"\n",1); 21 | } 22 | -------------------------------------------------------------------------------- /Exam01/rev_print.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i] != '\0') 6 | i++; 7 | return(i); 8 | } 9 | char *ft_rev_print (char *str) 10 | { 11 | int i = 0; 12 | int j = ft_strlen(str) -1; 13 | while(j >= i) 14 | { 15 | write(1,&str[j],1); 16 | j--; 17 | } 18 | return(str); 19 | } 20 | int main() 21 | { 22 | char str[] = "amassuO"; 23 | ft_rev_print(str); 24 | } 25 | -------------------------------------------------------------------------------- /Final-Exam/rev_print.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return i; 8 | } 9 | char *ft_rev_print (char *str) 10 | { 11 | int j = ft_strlen(str) -1; 12 | while(j >= 0) 13 | { 14 | write(1,&str[j],1); 15 | j--; 16 | } 17 | return str; 18 | } 19 | int main(void) 20 | { 21 | char str[] = "boxee99"; 22 | ft_rev_print(str); 23 | write(1,"\n",1); 24 | } 25 | -------------------------------------------------------------------------------- /Exam02/rotone.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i] != '\0') 8 | { 9 | if((av[1][i] >= 'a' && av[1][i] <= 'y') ||(av[1][i] >= 'A' && av[1][i] <= 'Y')) 10 | { 11 | av[1][i] += 1; 12 | }else if((av[1][i] == 'Z') || (av[1][i] == 'z')) 13 | { 14 | av[1][i] -= 25; 15 | } 16 | write(1,&av[1][i],1); 17 | i++; 18 | } 19 | } 20 | write(1,"\n",1); 21 | } 22 | -------------------------------------------------------------------------------- /Exam00/ft_interval.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i]) 8 | { 9 | if(i % 3 == 0 && i % 5 == 0) 10 | { 11 | av[1][i] = '5'; 12 | } 13 | else if(i % 3 == 0) 14 | { 15 | av[1][i] = '5'; 16 | } 17 | else if(i % 5 == 0) 18 | { 19 | av[1][i] = '3'; 20 | } 21 | write(1, &av[1][i], 1); 22 | i++; 23 | } 24 | } 25 | write(1, "\n", 1); 26 | } 27 | -------------------------------------------------------------------------------- /Exam01/ft_count_words.c: -------------------------------------------------------------------------------- 1 | 2 | int is_separator(char c) 3 | { 4 | if(c == ' ' || c == '\t') 5 | { 6 | return(0); 7 | }else 8 | return(1); 9 | } 10 | 11 | int ft_count_words(char *str) 12 | { 13 | int count = 0; 14 | 15 | while(*str) 16 | { 17 | while(*str != '\0' && !is_separator(*str)) 18 | str++; 19 | if(*str != '\0') 20 | { 21 | count++; 22 | } 23 | while(*str != '\0' && is_separator(*str)) 24 | str++; 25 | } 26 | return(count); 27 | } 28 | -------------------------------------------------------------------------------- /Exam01/ft_interval.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i]) 8 | { 9 | if(i % 3 == 0 && i % 5 == 0) 10 | { 11 | av[1][i] = '5'; 12 | } 13 | else if(i % 3 == 0) 14 | { 15 | av[1][i] = '5'; 16 | } 17 | else if(i % 5 == 0) 18 | { 19 | av[1][i] = '3'; 20 | } 21 | write(1, &av[1][i], 1); 22 | i++; 23 | } 24 | } 25 | write(1, "\n", 1); 26 | } 27 | -------------------------------------------------------------------------------- /Exam02/ft_count_words.c: -------------------------------------------------------------------------------- 1 | 2 | int is_separator(char c) 3 | { 4 | if(c == ' ' || c == '\t') 5 | { 6 | return(0); 7 | }else 8 | return(1); 9 | } 10 | 11 | int ft_count_words(char *str) 12 | { 13 | int count = 0; 14 | 15 | while(*str) 16 | { 17 | while(*str != '\0' && !is_separator(*str)) 18 | str++; 19 | if(*str != '\0') 20 | { 21 | count++; 22 | } 23 | while(*str != '\0' && is_separator(*str)) 24 | str++; 25 | } 26 | return(count); 27 | } 28 | -------------------------------------------------------------------------------- /Exam02/ft_interval.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i]) 8 | { 9 | if(i % 3 == 0 && i % 5 == 0) 10 | { 11 | av[1][i] = '5'; 12 | } 13 | else if(i % 3 == 0) 14 | { 15 | av[1][i] = '5'; 16 | } 17 | else if(i % 5 == 0) 18 | { 19 | av[1][i] = '3'; 20 | } 21 | write(1, &av[1][i], 1); 22 | i++; 23 | } 24 | } 25 | write(1, "\n", 1); 26 | } 27 | -------------------------------------------------------------------------------- /Final-Exam/ft_count_words.c: -------------------------------------------------------------------------------- 1 | 2 | int is_separator(char c) 3 | { 4 | if(c == ' ' || c == '\t') 5 | { 6 | return(0); 7 | }else 8 | return(1); 9 | } 10 | 11 | int ft_count_words(char *str) 12 | { 13 | int count = 0; 14 | 15 | while(*str) 16 | { 17 | while(*str != '\0' && !is_separator(*str)) 18 | str++; 19 | if(*str != '\0') 20 | { 21 | count++; 22 | } 23 | while(*str != '\0' && is_separator(*str)) 24 | str++; 25 | } 26 | return(count); 27 | } 28 | -------------------------------------------------------------------------------- /Final-Exam/ft_interval.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i]) 8 | { 9 | if(i % 3 == 0 && i % 5 == 0) 10 | { 11 | av[1][i] = '5'; 12 | } 13 | else if(i % 3 == 0) 14 | { 15 | av[1][i] = '5'; 16 | } 17 | else if(i % 5 == 0) 18 | { 19 | av[1][i] = '3'; 20 | } 21 | write(1, &av[1][i], 1); 22 | i++; 23 | } 24 | } 25 | write(1, "\n", 1); 26 | } 27 | -------------------------------------------------------------------------------- /Exam01/sum_even_position.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sum_even_position(char *str) 4 | { 5 | int i = 0; 6 | int sum = 0; 7 | while (str[i]) 8 | { 9 | if (i % 2 == 0 && str[i] >= '0' && str[i] <= '9') 10 | sum += str[i] - '0'; 11 | i++; 12 | } 13 | return (sum); 14 | } 15 | int main() 16 | { 17 | printf("%d\n", sum_even_position("12345")); 18 | printf("%d\n", sum_even_position("h2345")); 19 | printf("%d\n", sum_even_position("12hhh")); 20 | } -------------------------------------------------------------------------------- /Exam02/sum_even_position.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sum_even_position(char *str) 4 | { 5 | int i = 0; 6 | int sum = 0; 7 | while (str[i]) 8 | { 9 | if (i % 2 == 0 && str[i] >= '0' && str[i] <= '9') 10 | sum += str[i] - '0'; 11 | i++; 12 | } 13 | return (sum); 14 | } 15 | int main() 16 | { 17 | printf("%d\n", sum_even_position("12345")); 18 | printf("%d\n", sum_even_position("h2345")); 19 | printf("%d\n", sum_even_position("12hhh")); 20 | } -------------------------------------------------------------------------------- /Exam01/ft_strrev.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return(i); 8 | } 9 | char *ft_strrev(char *str) 10 | { 11 | int i = 0; 12 | int j = ft_strlen(str) -1 ; 13 | while(i < j) 14 | { 15 | char temp = str[j]; 16 | str[j] = str[i]; 17 | str[i] = temp; 18 | j--; 19 | i++; 20 | } 21 | return(str); 22 | } 23 | int main() 24 | { 25 | char str[] = "oussama"; 26 | printf("%s\n",ft_strrev(str)); 27 | } 28 | -------------------------------------------------------------------------------- /Exam01/rotone.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac,char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while(av[1][i] != '\0') 8 | { 9 | if((av[1][i] >= 'a' && av[1][i] <= 'y')|| (av[1][i] >= 'A' && av[1][i] <= 'Y')) 10 | { 11 | av[1][i] += 1; 12 | }else if(av[1][i] == 'z' || av[1][i] == 'Z') 13 | { 14 | av[1][i] -= 25; 15 | } 16 | write(1,&av[1][i],1); 17 | i++; 18 | } 19 | write(1,"\n",1); 20 | }else 21 | write(1,"\n",1); 22 | } 23 | -------------------------------------------------------------------------------- /Exam02/ft_strrev.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return i; 8 | } 9 | char *ft_strrev(char *str) 10 | { 11 | int i = 0; 12 | int j = ft_strlen(str) -1; 13 | while(i < j) 14 | { 15 | char temp = str[j]; 16 | str[j] = str[i]; 17 | str[i] = temp; 18 | i++; 19 | j--; 20 | } 21 | return(str); 22 | } 23 | int main() 24 | { 25 | char str[] = "amassO"; 26 | printf("%s\n",ft_strrev(str)); 27 | } 28 | -------------------------------------------------------------------------------- /Final-Exam/sum_even_position.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sum_even_position(char *str) 4 | { 5 | int i = 0; 6 | int sum = 0; 7 | while (str[i]) 8 | { 9 | if (i % 2 == 0 && str[i] >= '0' && str[i] <= '9') 10 | sum += str[i] - '0'; 11 | i++; 12 | } 13 | return (sum); 14 | } 15 | int main() 16 | { 17 | printf("%d\n", sum_even_position("12345")); 18 | printf("%d\n", sum_even_position("h2345")); 19 | printf("%d\n", sum_even_position("12hhh")); 20 | } -------------------------------------------------------------------------------- /Final-Exam/ft_strrev.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return i; 8 | } 9 | char *ft_strrev(char *str) 10 | { 11 | int i = 0; 12 | int j = ft_strlen(str) -1; 13 | while(i < j) 14 | { 15 | char temp = str[i]; 16 | str[i] = str[j]; 17 | str[j] = temp; 18 | i++; 19 | j--; 20 | } 21 | return (str); 22 | } 23 | int main(void) 24 | { 25 | char str[] = "boxee99"; 26 | printf("%s\n",ft_strrev(str)); 27 | } 28 | -------------------------------------------------------------------------------- /Exam02/rot_13.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0 ; 7 | while(av[1][i] != '\0') 8 | { 9 | if((av[1][i] >= 'a' && av[1][i] <= 'm') || (av[1][i] >= 'A' && av[1][i] <= 'M')) 10 | { 11 | av[1][i] += 13; 12 | }else if((av[1][i] >= 'n' && av[1][i] <= 'z') || (av[1][i] >= 'N' && av[1][i] <= 'Z')) 13 | { 14 | av[1][i] -= 13; 15 | } 16 | write(1,&av[1][i],1); 17 | i++; 18 | } 19 | } 20 | write(1,"\n",1); 21 | } 22 | -------------------------------------------------------------------------------- /Exam00/ft_strrev.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i] != '\0') 6 | { 7 | i++; 8 | } 9 | return(i); 10 | } 11 | char *ft_strrev(char *str) 12 | { 13 | int i = 0; 14 | int j = ft_strlen(str) -1; 15 | while(i < j) 16 | { 17 | char swap = str[i]; 18 | str[i] = str[j]; 19 | str[j] = swap; 20 | i++; 21 | j--; 22 | } 23 | return(str); 24 | } 25 | int main() 26 | { 27 | char str[] = "amassuO"; 28 | printf("%s\n",ft_strrev(str)); 29 | } 30 | -------------------------------------------------------------------------------- /Final-Exam/rle.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void ft_putchar(char c) 5 | { 6 | write(1, &c, 1); 7 | } 8 | 9 | int main(int ac, char **av) 10 | { 11 | if (ac == 2) 12 | { 13 | int i; 14 | int count; 15 | char c; 16 | 17 | i = 0; 18 | while (av[1][i]) 19 | { 20 | count = 0; 21 | c = av[1][i]; 22 | while (av[1][i] == c) 23 | { 24 | i++; 25 | count++; 26 | } 27 | if (count > 1) 28 | ft_putchar(count + '0'); 29 | ft_putchar(c); 30 | } 31 | } 32 | ft_putchar('\n'); 33 | } 34 | -------------------------------------------------------------------------------- /Exam02/last_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return(i); 8 | } 9 | int main(int ac, char **av) 10 | { 11 | if(ac == 2) 12 | { 13 | int j = ft_strlen(av[1]) -1; 14 | while(av[1][j] == ' ' || av[1][j] == '\t') 15 | j--; 16 | while(av[1][j] != ' ' && av[1][j] != '\t') 17 | j--; 18 | j++; 19 | while(av[1][j] != '\0' && (av[1][j] != ' ' && av[1][j] != '\t')) 20 | { 21 | write(1,&av[1][j],1); 22 | j++; 23 | } 24 | } 25 | write(1,"\n",1); 26 | } 27 | -------------------------------------------------------------------------------- /Final-Exam/fizzbuzz.c: -------------------------------------------------------------------------------- 1 | #include 2 | void put_numbers(int num) 3 | { 4 | if(num > 9) 5 | { 6 | put_numbers(num / 10); 7 | } 8 | write(1,&"0123456789"[num % 10],1); 9 | } 10 | int main() 11 | { 12 | int i = 1; 13 | while(i <= 100 ) 14 | { 15 | if(i % 3 == 0 && i % 5 == 0) 16 | { 17 | write(1,"fizzbuzz",8); 18 | }else if(i % 3 == 0) 19 | { 20 | write(1,"fizz",4); 21 | }else if(i % 5 == 0) 22 | { 23 | write(1,"buzz",4); 24 | }else 25 | put_numbers(i); 26 | write(1,"\n",1); 27 | i++; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /shell00/ex03/id_rsa_pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC3XqYyNYnt3afbMinhA7qBYIMh/ox4KdWmMvC9aYETGxVoPDM25FIQDv7C+RobzFnEI+bOMUMDLFfpXjjFzNh+yXs2O1SKJk3Ut705gelUa/B2QOga3/YaIyFEP03YbegCq+SaH2K5gPxrbAbQdlP0riD3KRigvdIleNjdEm4RgWI1Rn7Kd7HSmnJpzPxpG380OXV0pIHydinXaa6gwebf9Sf+4DtSSFv5EUMG6WlgTxIkmqaCKnHdKnrc+vFs7KvnFH+7akTUx6UrdwE0L2CZRO7FscHuXxj4GwdK8G6Tjx6e6BAKuJgKwPzWuV9AgR8wt0aSHpr0wNgPuIYKMZgWc/QGY9HLeDxkXdc6wEQtPWQIpzCZtjFNpiLUwKP1jJXJQkledNlocfV3p//ZFI7Ug67lPo3DFsM3I5fEixNqPo+KrpLplU9IWNdmVwZJEHHKgs/yga2Pmvj+GzBBh6L8mMuk9Dyj3XXy+ornbhK6jSAAOaFH6xsGZOxJcRfeAs8= ostouayr@e2r8p6.1337.ma 2 | -------------------------------------------------------------------------------- /shell00/ex07/b: -------------------------------------------------------------------------------- 1 | Episode V, A NEW H0PE It is a period of civil war 2 | Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. 3 | During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the STAR DEATH, an armored space station with enough power to destroy an entire planet. 4 | 5 | 6 | Pursued by the Empire's sinister agents, 7 | Princess Mehdi races home aboard her starship, custodian of the stolen plans that can save her people and restore the dictatorship to the galaxie.. 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Exam01/wdmatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i] != '\0') 6 | i++; 7 | return(i); 8 | } 9 | int main(int ac, char **av) 10 | { 11 | if(ac == 3) 12 | { 13 | int i = 0; 14 | int j = 0; 15 | while(av[1][i] != '\0' && av[2][j] != '\0') 16 | { 17 | if(av[1][i] == av[2][j]) 18 | i++; 19 | j++; 20 | } 21 | if(i == ft_strlen(av[1])) 22 | { 23 | i = 0; 24 | while (av[1][i]) 25 | { 26 | write(1,&av[1][i],1); 27 | i++; 28 | } 29 | } 30 | } 31 | write(1, "\n",1); 32 | } 33 | -------------------------------------------------------------------------------- /Exam02/wdmatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return i; 8 | } 9 | int main(int ac, char **av) 10 | { 11 | if(ac == 3) 12 | { 13 | int i = 0; 14 | int j = 0; 15 | while(av[1][i] != '\0' && av[2][j] != '\0') 16 | { 17 | if(av[1][i] == av[2][j]) 18 | { 19 | i++; 20 | } 21 | j++; 22 | } 23 | if(i == ft_strlen(av[1])) 24 | { 25 | i = 0; 26 | while(av[1][i] != '\0') 27 | { 28 | write(1,&av[1][i],1); 29 | i++; 30 | } 31 | } 32 | } 33 | write(1,"\n",1); 34 | } 35 | -------------------------------------------------------------------------------- /Exam01/rot_13.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(int ac, char **av) 3 | { 4 | if(ac == 2) 5 | { 6 | int i = 0; 7 | while (av[1][i] != '\0') 8 | { 9 | if((av[1][i] >= 'a' && av[1][i] <= 'm') || (av[1][i] >= 'A' && av[1][i] <= 'M')) 10 | { 11 | av[1][i] += 13; 12 | //write(1,&av[1][i],1); 13 | //av[1][i] -= 13; 14 | }else if((av[1][i] >= 'n' && av[1][i] <= 'z') || (av[1][i] >= 'N' && av[1][i] <= 'Z')) 15 | { 16 | av[1][i] -= 13; 17 | } 18 | write(1,&av[1][i],1); 19 | i++; 20 | } 21 | write(1,"\n",1); 22 | 23 | }else 24 | write(1,"\n",1); 25 | } 26 | -------------------------------------------------------------------------------- /Exam01/last_word.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_strlen(char *str) 3 | { 4 | int i = 0; 5 | while(str[i]) 6 | i++; 7 | return(i); 8 | } 9 | int main(int ac, char **av) 10 | { 11 | if(ac == 2) 12 | { 13 | int j = ft_strlen(av[1]) -1; 14 | while(av[1][j] == ' ' || av[1][j] == '\t') 15 | { 16 | j--; 17 | } 18 | while (av[1][j] != '\0' && av[1][j] != ' ' && av[1][j] != '\t') 19 | { 20 | j--; 21 | } 22 | j++; 23 | while(av[1][j] != '\0' && (av[1][j] != ' ' && av[1][j] != '\t')) 24 | { 25 | write(1,&av[1][j],1); 26 | j++; 27 | } 28 | } 29 | write(1,"\n",1); 30 | } 31 | -------------------------------------------------------------------------------- /Exam02/ft_atoi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_atoi(const char *str) 4 | { 5 | int i = 0; 6 | int sign = 1; 7 | while(str[i] == ' ' || (str[i] >= 9 && str[i] <= 13)) 8 | i++; 9 | if(str[i] == '-') 10 | { 11 | sign = -1; 12 | i++; 13 | }else if(str[i] == '+') 14 | i++; 15 | int convert = 0; 16 | while(str[i] != '\0' && (str[i] >= '0' && str[i] <= '9')) 17 | { 18 | convert = convert * 10 + str[i] - '0'; 19 | i++; 20 | } 21 | return(convert * sign); 22 | } 23 | int main() 24 | { 25 | char str[] = "22"; 26 | printf("ori: %d\n",atoi(str)); 27 | printf("my: %d\n",ft_atoi(str)); 28 | } 29 | -------------------------------------------------------------------------------- /Exam02/inter.c: -------------------------------------------------------------------------------- 1 | #include 2 | int is_inoutput(char *str, char c, int posi) 3 | { 4 | int i = 0; 5 | while(i < posi) 6 | { 7 | if(str[i] == c) 8 | { 9 | return(0); 10 | } 11 | i++; 12 | } 13 | return(1); 14 | } 15 | int main(int ac, char **av) 16 | { 17 | if(ac == 3) 18 | { 19 | int i = 0; 20 | while(av[1][i] != '\0') 21 | { 22 | int j = 0; 23 | while(av[2][j] != '\0') 24 | { 25 | if(av[1][i] == av[2][j] && is_inoutput(av[1],av[1][i],i) == 1) 26 | { 27 | write(1,&av[1][i],1); 28 | break; 29 | } 30 | j++; 31 | } 32 | i++; 33 | } 34 | } 35 | write(1,"\n",1); 36 | } 37 | -------------------------------------------------------------------------------- /Final-Exam/ft_atoi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_atoi(const char *str) 4 | { 5 | int i = 0; 6 | int sign = 1; 7 | while(str[i] == ' ' || (str[i] >= 9 && str[i] <= 13)) 8 | i++; 9 | if(str[i] == '-') 10 | { 11 | sign = -1; 12 | i++; 13 | }else if(str[i] == '+') 14 | { 15 | i++; 16 | } 17 | int convert = 0; 18 | while(str[i] != '\0' && (str[i] >= '0' && str[i] <= '9')) 19 | { 20 | convert = convert * 10 + str[i] - '0'; 21 | i++; 22 | } 23 | return(convert * sign); 24 | } 25 | int main(void) 26 | { 27 | char str[] = "\n\r99++"; 28 | printf("original is : %d\n",atoi(str)); 29 | printf("my func is : %d\n",ft_atoi(str)); 30 | } 31 | -------------------------------------------------------------------------------- /Exam00/ft_atoi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int ft_atoi(const char *str) 4 | { 5 | int i = 0; 6 | int count = 0; 7 | while(str[i] == ' ' || (str[i] >= 9 && str[i] <= 13)) 8 | i++; 9 | if(str[1] == '-') 10 | { 11 | count = -1; 12 | i++; 13 | }else if(str[i] == '+') 14 | i++; 15 | int convert = 0; 16 | while(str[i] != '\0' && (str[i] >= '0' && str[i] <= '9')) 17 | { 18 | convert = convert * 10 + str[i] - '0'; 19 | i++; 20 | } 21 | return(convert * count); 22 | } 23 | int main() 24 | { 25 | char nb[] = "-+55"; 26 | //printf("github func :%d\n",ft_atoi(nb)); 27 | printf("original:%d\n",atoi(nb)); 28 | printf("my func :%d\n",ft_atoi(nb)); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Exam01/inter.c: -------------------------------------------------------------------------------- 1 | #include 2 | int is_inoutput(char *str, char c, int posi) 3 | { 4 | int i = 0; 5 | while(i < posi) 6 | { 7 | if(str[i] == c) 8 | { 9 | return 0; 10 | } 11 | i++; 12 | } 13 | return 1; 14 | } 15 | int main(int ac, char **av) 16 | { 17 | if(ac == 3) 18 | { 19 | int i = 0; 20 | while(av[1][i] != '\0') 21 | { 22 | int j = 0; 23 | while(av[2][j] != '\0') 24 | { 25 | if(av[1][i] == av[2][j]) 26 | { 27 | if(is_inoutput(av[1],av[1][i],i) == 1) 28 | { 29 | write(1,&av[1][i],1); 30 | break; 31 | } 32 | } 33 | j++; 34 | } 35 | i++; 36 | } 37 | write(1,"\n",1); 38 | }else 39 | write(1,"\n",1); 40 | } 41 | -------------------------------------------------------------------------------- /Exam01/union.c: -------------------------------------------------------------------------------- 1 | #include 2 | int is_inoutput(char *str, char c, int posi) 3 | { 4 | int i = 0; 5 | while(i < posi) 6 | { 7 | if(str[i] == c) 8 | { 9 | return(0); 10 | } 11 | i++; 12 | } 13 | return 1; 14 | } 15 | int main(int ac, char **av) 16 | { 17 | if(ac == 3) 18 | { 19 | int i =0; 20 | while(av[1][i] != '\0') 21 | { 22 | if(is_inoutput(av[1],av[1][i], i) == 1) 23 | { 24 | write(1,&av[1][i],1); 25 | } 26 | i++; 27 | } 28 | int j = 0; 29 | while(av[2][j] != '\0') 30 | { 31 | if(is_inoutput(av[1],av[2][j],i) == 1 && is_inoutput(av[2],av[2][j],j) == 1) 32 | { 33 | write(1,&av[2][j],1); 34 | } 35 | j++; 36 | } 37 | } 38 | write(1,"\n",1); 39 | } 40 | -------------------------------------------------------------------------------- /Final-Exam/union.c: -------------------------------------------------------------------------------- 1 | #include 2 | int is_inoutput(char *str, char c,int posi) 3 | { 4 | int i = 0; 5 | while(i < posi) 6 | { 7 | if(str[i] == c) 8 | { 9 | return(0); 10 | } 11 | i++; 12 | } 13 | return 1; 14 | } 15 | int main(int ac,char **av) 16 | { 17 | if(ac == 3) 18 | { 19 | int i = 0; 20 | while(av[1][i] != '\0') 21 | { 22 | if(is_inoutput(av[1],av[1][i],i) == 1) 23 | { 24 | write(1,&av[1][i],1); 25 | } 26 | i++; 27 | } 28 | int j = 0; 29 | while(av[2][j] != '\0') 30 | { 31 | if(is_inoutput(av[1],av[2][j],i) == 1 && is_inoutput(av[2],av[2][j],j) == 1) 32 | { 33 | write(1,&av[2][j],1); 34 | } 35 | j++; 36 | } 37 | } 38 | write(1,"\n",1); 39 | } 40 | -------------------------------------------------------------------------------- /Exam02/union.c: -------------------------------------------------------------------------------- 1 | #include 2 | int ft_isinoutput(char *str,char c, int posi) 3 | { 4 | int i = 0; 5 | while(i < posi) 6 | { 7 | if(str[i] == c) 8 | { 9 | return(0); 10 | } 11 | i++; 12 | } 13 | return(1); 14 | } 15 | int main(int ac, char **av) 16 | { 17 | if(ac == 3) 18 | { 19 | int i = 0; 20 | while(av[1][i] != '\0') 21 | { 22 | if(ft_isinoutput(av[1],av[1][i],i) == 1) 23 | { 24 | write(1,&av[1][i],1); 25 | } 26 | i++; 27 | } 28 | int j = 0; 29 | while (av[2][j] != '\0') 30 | { 31 | if(ft_isinoutput(av[2],av[2][j],j) == 1 && ft_isinoutput(av[1],av[2][j], i) == 1) 32 | { 33 | write(1,&av[2][j],1); 34 | } 35 | j++; 36 | } 37 | } 38 | write(1,"\n",1); 39 | } 40 | -------------------------------------------------------------------------------- /Exam02/title.c: -------------------------------------------------------------------------------- 1 | #include 2 | int is_print(char c) 3 | { 4 | if( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) 5 | { 6 | return(1); 7 | }else 8 | return(0); 9 | } 10 | int main(int ac,char **av) 11 | { 12 | if(ac == 2) 13 | { 14 | int i = 0; 15 | int should_cap = 1; 16 | while(av[1][i] != '\0') 17 | { 18 | if(is_print(av[1][i])) 19 | { 20 | if(should_cap && av[1][i] >= 'a' && av[1][i] <= 'z') 21 | { 22 | av[1][i] -= 32; 23 | write(1, &av[1][i], 1); 24 | should_cap = 0; 25 | }else if(!should_cap && av[1][i] >= 'A'&& av[1][i] <= 'Z') 26 | { 27 | av[1][i] += 32; 28 | write(1, &av[1][i], 1); 29 | }else 30 | write(1, &av[1][i], 1); 31 | should_cap = 0; 32 | }else 33 | { 34 | write(1,&av[1][i], 1); 35 | should_cap = 1; 36 | } 37 | i++; 38 | } 39 | } 40 | write(1,"\n", 1); 41 | } 42 | -------------------------------------------------------------------------------- /Final-Exam/title.c: -------------------------------------------------------------------------------- 1 | #include 2 | int is_print(char c) 3 | { 4 | if( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) 5 | { 6 | return(1); 7 | }else 8 | return(0); 9 | } 10 | int main(int ac,char **av) 11 | { 12 | if(ac == 2) 13 | { 14 | int i = 0; 15 | int should_cap = 1; 16 | while(av[1][i] != '\0') 17 | { 18 | if(is_print(av[1][i])) 19 | { 20 | if(should_cap && av[1][i] >= 'a' && av[1][i] <= 'z') 21 | { 22 | av[1][i] -= 32; 23 | write(1, &av[1][i], 1); 24 | should_cap = 0; 25 | }else if(!should_cap && av[1][i] >= 'A'&& av[1][i] <= 'Z') 26 | { 27 | av[1][i] += 32; 28 | write(1, &av[1][i], 1); 29 | }else 30 | write(1, &av[1][i], 1); 31 | should_cap = 0; 32 | }else 33 | { 34 | write(1,&av[1][i], 1); 35 | should_cap = 1; 36 | } 37 | i++; 38 | } 39 | } 40 | write(1,"\n", 1); 41 | } 42 | -------------------------------------------------------------------------------- /Final-Exam/ft_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int *ft_range(int start, int end) 4 | { 5 | int size ; 6 | if(start <= end) 7 | { 8 | size = end - start + 1; 9 | }else 10 | size = start - end + 1; 11 | int *range = (int*) malloc(size * sizeof(int)); 12 | if(range == NULL) 13 | { 14 | return NULL; 15 | } 16 | int i = 0; 17 | if(start <= end) 18 | { 19 | while(start <= end) 20 | { 21 | range[i] = start; 22 | start++; 23 | i++; 24 | } 25 | }else 26 | { 27 | while(start>= end) 28 | { 29 | range[i] = start; 30 | start--; 31 | i++; 32 | } 33 | } 34 | return(range); 35 | } 36 | int main() 37 | { 38 | int start = 5; 39 | int end = 10; 40 | int *range = ft_range(start,end); 41 | int size = end - start + 1; 42 | int i = 0; 43 | while(i < size ) 44 | { 45 | printf("%d ,",range[i]); 46 | i++; 47 | } 48 | printf("\n"); 49 | } 50 | -------------------------------------------------------------------------------- /Exam02/ft_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int *ft_range(int start, int end) 4 | { 5 | int size = 0; 6 | if(start >= end) 7 | { 8 | size = start - end + 1; 9 | }else 10 | { 11 | size = end - start + 1; 12 | } 13 | int *range = (int*) malloc(size *sizeof(int)); 14 | if(range == NULL) 15 | { 16 | return NULL; 17 | } 18 | int i = 0; 19 | if(start >= end) 20 | { 21 | while(start >= end) 22 | { 23 | range[i] = start; 24 | start--; 25 | i++; 26 | } 27 | }else 28 | { 29 | while(start <= end) 30 | { 31 | range[i]= start; 32 | start++; 33 | i++; 34 | } 35 | } 36 | return(range); 37 | } 38 | int main() 39 | { 40 | int start = 1; 41 | int end = 1; 42 | int size = end - start + 1; 43 | int *range = ft_range(start,end); 44 | int i = 0; 45 | while( i < size) 46 | { 47 | printf("%d, ",range[i]); 48 | i++; 49 | } 50 | printf("\n"); 51 | free(range); 52 | } 53 | -------------------------------------------------------------------------------- /C01/ex00/ft_ft.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ft.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 13:43:28 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 13:54:14 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_ft(int *nbr) 14 | { 15 | *nbr = 42; 16 | } 17 | -------------------------------------------------------------------------------- /Exam01/ft_range.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int *ft_range(int start, int end) 4 | { 5 | int size; 6 | if(start <= end) 7 | { 8 | size = end - start + 1; // not dima : size = (lkbira - sghira + 1) 9 | }else 10 | size = start - end + 1; 11 | 12 | int *range = (int*) malloc(size * sizeof(int)); 13 | if(range == NULL) 14 | return NULL; 15 | 16 | int index = 0; 17 | if(start <= end) 18 | { 19 | while(start <= end) 20 | { 21 | range[index] = start; 22 | start++; 23 | index++; 24 | } 25 | }else 26 | { 27 | while(start >= end) 28 | { 29 | range[index] = start; 30 | start--; 31 | index++; 32 | } 33 | } 34 | return(range); 35 | } 36 | /*int main() 37 | { 38 | int start = -10; 39 | int end = -30; 40 | int *range = ft_range(start,end); 41 | int size = start - end + 1; 42 | int i = 0; 43 | while(i < size) 44 | { 45 | printf("%d, ",range[i]); 46 | i++; 47 | } 48 | printf("\n"); 49 | free(range); 50 | }*/ 51 | -------------------------------------------------------------------------------- /C01/ex01/ft_ultimate_ft.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ultimate_ft.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 13:57:28 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 14:44:39 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_ultimate_ft(int *********nbr) 14 | { 15 | *********nbr = 42; 16 | } 17 | -------------------------------------------------------------------------------- /C00/ex00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/26 15:43:13 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/26 20:11:34 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | -------------------------------------------------------------------------------- /C09/ex00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/16 11:46:20 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/16 11:47:18 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | -------------------------------------------------------------------------------- /rush00/ft_putchar.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 17:03:05 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 17:03:35 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | -------------------------------------------------------------------------------- /rush00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 17:03:52 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 21:59:53 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void rush(int y, int x); 14 | 15 | int main(void) 16 | { 17 | rush(-4, 4); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /C01/ex03/ft_div_mod.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_div_mod.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 16:01:08 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 16:12:32 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_div_mod(int a, int b, int *div, int *mod) 14 | { 15 | *div = a / b; 16 | *mod = a % b; 17 | } 18 | -------------------------------------------------------------------------------- /C01/ex02/ft_swap.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swap.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 15:32:40 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 15:40:16 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_swap(int *a, int *b) 14 | { 15 | int temp; 16 | 17 | temp = *a; 18 | *a = *b; 19 | *b = temp; 20 | } 21 | -------------------------------------------------------------------------------- /C08/ex02/ft_abs.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_abs.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/14 15:48:32 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/14 15:56:55 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_ABS_H 14 | # define FT_ABS_H 15 | 16 | # define ABS(x) (x * (x >= 0) - x * (x < 0)) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /C09/ex00/ft_swap.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swap.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/16 11:48:23 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/16 11:48:37 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_swap(int *a, int *b) 14 | { 15 | int temp; 16 | 17 | temp = *a; 18 | *a = *b; 19 | *b = temp; 20 | } 21 | -------------------------------------------------------------------------------- /C04/ex00/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/02 22:36:39 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/02 22:38:11 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strlen(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i]) 19 | i++; 20 | return (i); 21 | } 22 | -------------------------------------------------------------------------------- /C09/ex00/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/16 11:50:05 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/16 11:50:27 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strlen(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i]) 19 | i++; 20 | return (i); 21 | } 22 | -------------------------------------------------------------------------------- /C01/ex06/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 16:50:38 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 17:20:38 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strlen(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i]) 19 | { 20 | i++; 21 | } 22 | return (i); 23 | } 24 | -------------------------------------------------------------------------------- /C08/ex03/ft_point.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_point.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/14 15:58:13 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/15 14:02:54 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_POINT_H 14 | # define FT_POINT_H 15 | 16 | typedef struct s_point 17 | { 18 | int y; 19 | int x; 20 | } t_point; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /C01/ex04/ft_ultimate_div_mod.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ultimate_div_mod.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 16:14:12 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 16:31:01 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_ultimate_div_mod(int *a, int *b) 14 | { 15 | int temp; 16 | 17 | temp = *a; 18 | *a = *a / *b; 19 | *b = temp % *b; 20 | } 21 | -------------------------------------------------------------------------------- /C08/ex00/ft.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/10 10:40:25 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/13 16:59:32 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_putchar(char c); 14 | void ft_swap(int *a, int *b); 15 | void ft_putstr(char *str); 16 | int ft_strlen(char *str); 17 | int ft_strcmp(char *s1, char *s2); 18 | -------------------------------------------------------------------------------- /C00/ex04/ft_is_negative.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_is_negative.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/26 21:16:06 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/26 21:22:02 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_is_negative(int n) 16 | { 17 | if (n < 0) 18 | { 19 | write(1, "N", 1); 20 | } 21 | else 22 | write(1, "P", 1); 23 | } 24 | -------------------------------------------------------------------------------- /C04/ex01/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/03 10:02:56 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/03 10:05:34 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | { 22 | write(1, &str[i], 1); 23 | i++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C09/ex00/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/16 11:49:32 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/16 11:49:34 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | { 22 | write(1, &str[i], 1); 23 | i++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C00/ex03/ft_print_numbers.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_numbers.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/26 21:09:57 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/26 21:13:05 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_numbers(void) 16 | { 17 | char n; 18 | 19 | n = '0'; 20 | while (n <= '9') 21 | { 22 | write(1, &n, 1); 23 | n++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C01/ex05/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 16:35:49 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 16:47:13 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | write(1, &str[i], 1); 23 | i++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Exam02/ft_rrange.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int *ft_rrange(int start, int end) 4 | { 5 | int size; 6 | long dep = start; 7 | long fin = end; 8 | if(dep >= fin) 9 | { 10 | size = dep - fin + 1; 11 | }else 12 | size = fin - dep + 1; 13 | int *rrange = (int *) malloc(size * sizeof(int)); 14 | if(!rrange) 15 | { 16 | return(NULL); 17 | } 18 | int i = 0; 19 | if(dep >= fin) 20 | { 21 | while(dep >= fin) 22 | { 23 | rrange[i] = fin; 24 | fin++; 25 | i++; 26 | } 27 | }else if(fin >= dep) 28 | { 29 | while(fin >= dep) 30 | { 31 | rrange[i] = fin; 32 | fin--; 33 | i++; 34 | } 35 | } 36 | return(rrange); 37 | } 38 | int main() 39 | { 40 | int i = 0; 41 | int size = 0; 42 | int start = 2147483647; 43 | int end = 2147483647; 44 | int *rrange = ft_rrange(start,end); 45 | if(start >= end) 46 | { 47 | size = start - end + 1; 48 | }else if(end >= start) 49 | { 50 | size = end - start + 1; 51 | } 52 | while(i < size) 53 | { 54 | printf("%d, ",rrange[i]); 55 | i++; 56 | } 57 | printf("\n"); 58 | } 59 | -------------------------------------------------------------------------------- /C00/ex01/ft_print_alphabet.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_alphabet.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/26 20:34:01 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/26 20:58:32 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_alphabet(void) 16 | { 17 | char c; 18 | 19 | c = 'a'; 20 | while (c <= 'z') 21 | { 22 | write(1, &c, 1); 23 | c++; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C08/ex04/ft_stock_str.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_stock_str.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/14 22:00:14 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/15 18:08:07 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_STOCK_STR_H 14 | # define FT_STOCK_STR_H 15 | 16 | typedef struct s_stock_str 17 | { 18 | int size; 19 | char *str; 20 | char *copy; 21 | } t_stock_str; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /C08/ex05/ft_stock_str.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_stock_str.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/14 22:00:14 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/15 18:09:32 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_STOCK_STR_H 14 | # define FT_STOCK_STR_H 15 | 16 | typedef struct s_stock_str 17 | { 18 | int size; 19 | char *str; 20 | char *copy; 21 | } t_stock_str; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Final-Exam/ft_rrange.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int *ft_rrange(int start, int end) 4 | { 5 | int size; 6 | long dep = start; 7 | long fin = end; 8 | if(dep >= fin) 9 | { 10 | size = dep - fin + 1; 11 | }else 12 | size = fin - dep + 1; 13 | int *rrange = (int *) malloc(size * sizeof(int)); 14 | if(!rrange) 15 | { 16 | return(NULL); 17 | } 18 | int i = 0; 19 | if(dep >= fin) 20 | { 21 | while(dep >= fin) 22 | { 23 | rrange[i] = fin; 24 | fin++; 25 | i++; 26 | } 27 | }else if(fin >= dep) 28 | { 29 | while(fin >= dep) 30 | { 31 | rrange[i] = fin; 32 | fin--; 33 | i++; 34 | } 35 | } 36 | return(rrange); 37 | } 38 | int main() 39 | { 40 | int i = 0; 41 | int size = 0; 42 | int start = 2147483647; 43 | int end = 2147483647; 44 | int *rrange = ft_rrange(start,end); 45 | if(start >= end) 46 | { 47 | size = start - end + 1; 48 | }else if(end >= start) 49 | { 50 | size = end - start + 1; 51 | } 52 | while(i < size) 53 | { 54 | printf("%d, ",rrange[i]); 55 | i++; 56 | } 57 | printf("\n"); 58 | } 59 | -------------------------------------------------------------------------------- /C03/ex00/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/01 09:29:05 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/01 10:15:43 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strcmp(char *s1, char *s2) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (s1[i] != '\0' && s2[i] != '\0' && s1[i] == s2[i]) 19 | { 20 | i++; 21 | } 22 | return (s1[i] - s2[i]); 23 | } 24 | -------------------------------------------------------------------------------- /C09/ex00/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/16 11:51:04 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/16 13:53:24 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strcmp(char *s1, char *s2) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (s1[i] != '\0' && s2[i] != '\0' && s1[i] == s2[i]) 19 | { 20 | i++; 21 | } 22 | return (s1[i] - s2[i]); 23 | } 24 | -------------------------------------------------------------------------------- /C00/ex02/ft_print_reverse_alphabet.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_reverse_alphabet.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/26 21:00:13 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/26 21:07:48 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_reverse_alphabet(void) 16 | { 17 | char c; 18 | 19 | c = 'z'; 20 | while (c >= 'a') 21 | { 22 | write(1, &c, 1); 23 | c--; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C02/ex00/ft_strcpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/28 10:15:12 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/28 10:18:20 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strcpy(char *dest, char *src) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (src[i] != '\0') 19 | { 20 | dest[i] = src[i]; 21 | i++; 22 | } 23 | dest[i] = '\0'; 24 | return (dest); 25 | } 26 | -------------------------------------------------------------------------------- /C02/ex07/ft_strupcase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strupcase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 18:13:49 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 20:55:42 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strupcase(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | if (str[i] >= 97 && str[i] <= 122) 21 | { 22 | str[i] -= 32; 23 | } 24 | i++; 25 | } 26 | return (str); 27 | } 28 | -------------------------------------------------------------------------------- /C02/ex08/ft_strlowcase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlowcase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 20:57:32 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 21:02:52 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strlowcase(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | if (str[i] >= 65 && str[i] <= 90) 21 | { 22 | str[i] += 32; 23 | } 24 | i++; 25 | } 26 | return (str); 27 | } 28 | -------------------------------------------------------------------------------- /C02/ex03/ft_str_is_numeric.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_numeric.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 10:52:09 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 11:01:42 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_str_is_numeric(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | if (!(str[i] >= 48 && str[i] <= 57)) 21 | { 22 | return (0); 23 | } 24 | i++; 25 | } 26 | return (1); 27 | } 28 | -------------------------------------------------------------------------------- /C05/ex01/ft_recursive_factorial.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_recursive_factorial.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/06 17:05:07 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/06 18:59:43 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_recursive_factorial(int nb) 14 | { 15 | if (nb < 0) 16 | return (0); 17 | if (nb == 0 || nb == 1) 18 | { 19 | return (1); 20 | } 21 | else 22 | { 23 | return (nb * ft_recursive_factorial(nb - 1)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /C02/ex05/ft_str_is_uppercase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_uppercase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 18:07:17 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 18:10:24 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_str_is_uppercase(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | if (!(str[i] >= 65 && str[i] <= 90)) 21 | { 22 | return (0); 23 | } 24 | i++; 25 | } 26 | return (1); 27 | } 28 | -------------------------------------------------------------------------------- /C02/ex06/ft_str_is_printable.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_printable.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 17:44:16 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 20:55:02 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_str_is_printable(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | if (!(str[i] >= 32 && str[i] <= 126)) 21 | { 22 | return (0); 23 | } 24 | i++; 25 | } 26 | return (1); 27 | } 28 | -------------------------------------------------------------------------------- /C03/ex01/ft_strncmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/01 09:43:03 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/01 10:19:37 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strncmp(char *s1, char *s2, unsigned int n) 14 | { 15 | unsigned int i; 16 | 17 | i = 0; 18 | while (s1[i] == s2[i] && (s1[i] != '\0' && i < n)) 19 | { 20 | i++; 21 | } 22 | if (i == n) 23 | return (0); 24 | return (s1[i] - s2[i]); 25 | } 26 | -------------------------------------------------------------------------------- /C05/ex06/ft_is_prime.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_is_prime.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 13:56:20 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 15:25:41 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_is_prime(int nb) 14 | { 15 | int i; 16 | 17 | if (nb <= 1) 18 | { 19 | return (0); 20 | } 21 | i = 2; 22 | while (i <= nb / i) 23 | { 24 | if (nb % i == 0) 25 | { 26 | return (0); 27 | } 28 | i++; 29 | } 30 | return (1); 31 | } 32 | -------------------------------------------------------------------------------- /C05/ex00/ft_iterative_factorial.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_iterative_factorial.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/06 15:43:25 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/06 16:22:06 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_iterative_factorial(int nb) 14 | { 15 | int i; 16 | int res; 17 | 18 | if (nb < 0) 19 | { 20 | return (0); 21 | } 22 | res = 1; 23 | i = 1; 24 | while (i <= nb) 25 | { 26 | res *= i; 27 | i++; 28 | } 29 | return (res); 30 | } 31 | -------------------------------------------------------------------------------- /C05/ex03/ft_recursive_power.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_recursive_power.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 10:28:30 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 10:35:18 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_recursive_power(int nb, int power) 14 | { 15 | if (power < 0) 16 | { 17 | return (0); 18 | } 19 | else if (power == 0) 20 | { 21 | return (1); 22 | } 23 | else 24 | { 25 | return (nb * ft_recursive_power(nb, power -1)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /C01/ex07/ft_rev_int_tab.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rev_int_tab.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 17:24:09 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 17:50:11 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_rev_int_tab(int *tab, int size) 14 | { 15 | int i; 16 | int j; 17 | int temp; 18 | 19 | i = 0; 20 | j = size -1; 21 | while (i < j) 22 | { 23 | temp = tab[i]; 24 | tab[i] = tab[j]; 25 | tab[j] = temp; 26 | j--; 27 | i++; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /C06/ex00/ft_print_program_name.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_program_name.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 17:00:49 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 19:59:49 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | int i; 18 | 19 | if (ac >= 1) 20 | { 21 | i = 0; 22 | while (av[0][i] != '\0') 23 | { 24 | write(1, &av[0][i], 1); 25 | i++; 26 | } 27 | } 28 | write(1, "\n", 1); 29 | } 30 | -------------------------------------------------------------------------------- /C02/ex04/ft_str_is_lowercase.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_lowercase.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 11:28:10 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 14:16:14 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_lowercase(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i] != '\0') 21 | { 22 | if (!(str[i] >= 97 && str[i] <= 122)) 23 | { 24 | return (0); 25 | } 26 | i++; 27 | } 28 | return (1); 29 | } 30 | -------------------------------------------------------------------------------- /C02/ex01/ft_strncpy.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncpy.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/28 10:22:59 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/28 11:45:13 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strncpy(char *dest, char *src, unsigned int n) 14 | { 15 | unsigned int i; 16 | 17 | i = 0; 18 | while (i < n && src[i] != '\0') 19 | { 20 | dest[i] = src[i]; 21 | i++; 22 | } 23 | while (i < n) 24 | { 25 | dest[i] = '\0'; 26 | i++; 27 | } 28 | return (dest); 29 | } 30 | -------------------------------------------------------------------------------- /C02/ex02/ft_str_is_alpha.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_str_is_alpha.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/28 11:47:16 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/28 13:47:30 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_str_is_alpha(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i] != '\0') 19 | { 20 | if (!((str[i] >= 65 && str[i] <= 90) 21 | || (str[i] >= 97 && str[i] <= 122))) 22 | { 23 | return (0); 24 | } 25 | else 26 | i++; 27 | } 28 | return (1); 29 | } 30 | -------------------------------------------------------------------------------- /C03/ex02/ft_strcat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/01 10:24:17 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/01 10:39:20 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strcat(char *dest, char *src) 14 | { 15 | int i; 16 | int j; 17 | 18 | i = 0; 19 | while (dest[i] != '\0') 20 | { 21 | i++; 22 | } 23 | j = 0; 24 | while (src[j] != '\0') 25 | { 26 | dest[i] = src[j]; 27 | j++; 28 | i++; 29 | } 30 | dest[i] = '\0'; 31 | return (dest); 32 | } 33 | -------------------------------------------------------------------------------- /C05/ex04/ft_fibonacci.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fibonacci.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 11:30:35 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 11:40:33 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_fibonacci(int index) 14 | { 15 | if (index < 0) 16 | { 17 | return (-1); 18 | } 19 | else if (index == 0) 20 | { 21 | return (0); 22 | } 23 | else if (index == 1) 24 | { 25 | return (1); 26 | } 27 | else 28 | { 29 | return (ft_fibonacci(index - 1) + ft_fibonacci(index -2)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /C05/ex05/ft_sqrt.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sqrt.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 11:48:14 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 13:49:50 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_sqrt(int nb) 14 | { 15 | int i; 16 | 17 | if (nb < 0) 18 | { 19 | return (0); 20 | } 21 | else if (nb == 0 || nb == 1) 22 | { 23 | return (nb); 24 | } 25 | i = 0; 26 | while (i <= 46340) 27 | { 28 | if (i * i == nb) 29 | { 30 | return (i); 31 | } 32 | i++; 33 | } 34 | return (0); 35 | } 36 | -------------------------------------------------------------------------------- /C05/ex02/ft_iterative_power.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_iterative_power.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 09:11:22 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 10:25:47 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_iterative_power(int nb, int power) 14 | { 15 | int i; 16 | int count; 17 | 18 | if (power < 0) 19 | { 20 | return (0); 21 | } 22 | else if (power == 0 && nb == 0) 23 | return (1); 24 | i = 0; 25 | count = 1; 26 | while (i < power) 27 | { 28 | count = count * nb; 29 | i++; 30 | } 31 | return (count); 32 | } 33 | -------------------------------------------------------------------------------- /C06/ex01/ft_print_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 20:15:08 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 21:43:02 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | int i; 18 | int j; 19 | 20 | if (ac > 1) 21 | { 22 | i = 1; 23 | while (i < ac) 24 | { 25 | j = 0; 26 | while (av[i][j]) 27 | { 28 | write(1, &av[i][j], 1); 29 | j++; 30 | } 31 | write(1, "\n", 1); 32 | i++; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /C06/ex02/ft_rev_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rev_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 21:40:19 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 22:09:12 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int main(int ac, char **av) 16 | { 17 | int i; 18 | int j; 19 | 20 | if (ac > 1) 21 | { 22 | i = ac -1; 23 | while (i >= 1) 24 | { 25 | j = 0; 26 | while (av[i][j]) 27 | { 28 | write(1, &av[i][j], 1); 29 | j++; 30 | } 31 | write(1, "\n", 1); 32 | i--; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /C03/ex03/ft_strncat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strncat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/01 11:24:44 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/01 11:58:33 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strncat(char *dest, char *src, unsigned int nb) 14 | { 15 | unsigned int i; 16 | unsigned int j; 17 | 18 | i = 0; 19 | while (dest[i] != '\0') 20 | { 21 | i++; 22 | } 23 | j = 0; 24 | while (src[j] != '\0' && j < nb) 25 | { 26 | dest[i] = src[j]; 27 | i++; 28 | j++; 29 | } 30 | dest[i] = '\0'; 31 | return (dest); 32 | } 33 | -------------------------------------------------------------------------------- /C08/ex01/ft_boolean.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_boolean.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/10 11:46:56 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/15 20:17:21 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_BOOLEAN_H 14 | # define FT_BOOLEAN_H 15 | 16 | # include 17 | 18 | typedef int t_bool; 19 | 20 | # define TRUE 1 21 | # define FALSE 0 22 | # define EVEN(nbr) ((nbr) % 2 == 0) 23 | # define EVEN_MSG "I have an even number of arguments.\n" 24 | # define ODD_MSG "I have an odd number of arguments.\n" 25 | # define SUCCESS 0 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /C01/ex08/ft_sort_int_tab.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sort_int_tab.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 20:29:11 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 21:35:37 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_sort_int_tab(int *tab, int size) 14 | { 15 | int i; 16 | int j; 17 | int temp; 18 | 19 | i = 0; 20 | while (i < size) 21 | { 22 | j = 0; 23 | while (j < size -1) 24 | { 25 | if (tab[j] > tab[j + 1]) 26 | { 27 | temp = tab[j]; 28 | tab[j] = tab[j + 1]; 29 | tab[j + 1] = temp; 30 | } 31 | j++; 32 | } 33 | i++; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /C05/ex07/ft_find_next_prime.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_find_next_prime.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 15:27:51 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/07 16:22:00 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_is_prime(int nb) 14 | { 15 | int i; 16 | 17 | if (nb <= 1) 18 | { 19 | return (0); 20 | } 21 | i = 2; 22 | while (i <= nb / i) 23 | { 24 | if (nb % i == 0) 25 | { 26 | return (0); 27 | } 28 | i++; 29 | } 30 | return (1); 31 | } 32 | 33 | int ft_find_next_prime(int nb) 34 | { 35 | while (!ft_is_prime(nb)) 36 | { 37 | nb++; 38 | } 39 | return (nb); 40 | } 41 | -------------------------------------------------------------------------------- /C07/ex01/ft_range.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_range.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/08 15:43:19 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/08 17:07:35 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int *ft_range(int min, int max) 16 | { 17 | int size; 18 | int *range; 19 | int i; 20 | 21 | size = max - min; 22 | if (min >= max) 23 | return (0); 24 | range = (int *) malloc(size * sizeof(int)); 25 | if (!range) 26 | return (0); 27 | i = 0; 28 | while (i < size) 29 | { 30 | range[i] = min; 31 | i++; 32 | min++; 33 | } 34 | return (range); 35 | } 36 | -------------------------------------------------------------------------------- /C07/ex00/ft_strdup.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strdup.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/08 09:50:49 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/08 14:06:03 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strdup(char *src) 16 | { 17 | int count; 18 | char 19 | *dup; 20 | 21 | count = 0; 22 | while (src[count]) 23 | count++; 24 | dup = (char *) malloc(count * sizeof(char) + 1); 25 | if (!dup) 26 | return (0); 27 | count = 0; 28 | while (src[count]) 29 | { 30 | dup[count] = src[count]; 31 | count++; 32 | } 33 | dup[count] = '\0'; 34 | return (dup); 35 | } 36 | -------------------------------------------------------------------------------- /C03/ex04/ft_strstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/01 13:40:53 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/01 21:21:34 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | char *ft_strstr(char *str, char *to_find) 14 | { 15 | int i; 16 | int j; 17 | 18 | i = 0; 19 | j = 0; 20 | if (to_find[j] == '\0') 21 | return (str); 22 | while (str[i]) 23 | { 24 | j = 0; 25 | while (to_find[j] && str[i] == to_find[j]) 26 | { 27 | i++; 28 | j++; 29 | } 30 | i -= j; 31 | if (to_find[j] == '\0') 32 | { 33 | return (str + i); 34 | } 35 | else 36 | i++; 37 | } 38 | return (0); 39 | } 40 | -------------------------------------------------------------------------------- /Final-Exam/nth_char.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int check_numbers(char *str) 4 | { 5 | int i = 0; 6 | while (str[i]) 7 | { 8 | if (str[i] >= '0' && str[i] <= '9') 9 | return (0); 10 | i++; 11 | } 12 | return (1); 13 | } 14 | int check_chars(char *str) 15 | { 16 | int i = 0; 17 | while (str[i]) 18 | { 19 | if (str[i] < '0' || str[i] > '9') 20 | return (0); 21 | i++; 22 | } 23 | return (1); 24 | } 25 | 26 | int ft_atoi(char *str) 27 | { 28 | int i = 0; 29 | int sign = 1; 30 | while(str[i] == ' ' || (str[i] >= 9 && str[i] <= 13)) 31 | i++; 32 | if(str[i] == '-') 33 | { 34 | sign = -1; 35 | i++; 36 | }else if(str[i] == '+') 37 | { 38 | i++; 39 | } 40 | int convert = 0; 41 | while(str[i] != '\0' && (str[i] >= '0' && str[i] <= '9')) 42 | { 43 | convert = convert * 10 + str[i] - '0'; 44 | i++; 45 | } 46 | return(convert * sign); 47 | } 48 | 49 | int main(int ac, char **av) 50 | { 51 | if (ac == 3) 52 | { 53 | int i = 0; 54 | int j = 0; 55 | if (!check_numbers(av[1])) 56 | return (write(1, "\n", 1), 0); 57 | else if (!check_chars(av[2])) 58 | return (write(1, "\n", 1), 0); 59 | int number = ft_atoi(av[2]); 60 | while (av[1][j]) 61 | { 62 | i++; 63 | if (i == number) 64 | { 65 | write(1, &av[1][j], 1); 66 | i = 0; 67 | } 68 | j++; 69 | } 70 | write(1, "\n", 1); 71 | } 72 | else 73 | write(1, "\n", 1); 74 | } 75 | -------------------------------------------------------------------------------- /C00/ex05/ft_print_comb.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_comb.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/26 21:28:32 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 09:28:58 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_print_comb(void) 16 | { 17 | char i; 18 | char j; 19 | char k; 20 | 21 | i = '0'; 22 | while (i <= '7') 23 | { 24 | j = i + 1; 25 | while (j <= '8') 26 | { 27 | k = j + 1; 28 | while (k <= '9') 29 | { 30 | write(1, &i, 1); 31 | write(1, &j, 1); 32 | write(1, &k, 1); 33 | if (i != '7') 34 | write(1, ", ", 2); 35 | k++; 36 | } 37 | j++; 38 | } 39 | i++; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /C00/ex07/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 10:13:16 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 10:36:11 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_putnbr(int nb) 21 | { 22 | if (nb == -2147483648) 23 | { 24 | write(1, "-2147483648", 11); 25 | } 26 | else if (nb < 0) 27 | { 28 | nb *= -1; 29 | ft_putchar('-'); 30 | ft_putnbr(nb); 31 | } 32 | else if (nb < 10) 33 | { 34 | ft_putchar(nb + '0'); 35 | } 36 | else 37 | { 38 | ft_putnbr(nb / 10); 39 | ft_putnbr(nb % 10); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /C04/ex02/ft_putnbr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/03 10:07:30 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/03 11:27:14 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_putnbr(int nb) 21 | { 22 | if (nb == -2147483648) 23 | { 24 | write(1, "-2147483648", 11); 25 | } 26 | else if (nb < 0) 27 | { 28 | nb *= -1; 29 | ft_putchar('-'); 30 | ft_putnbr(nb); 31 | } 32 | else if (nb < 10) 33 | { 34 | ft_putchar(nb + '0'); 35 | } 36 | else 37 | { 38 | ft_putnbr(nb / 10); 39 | ft_putnbr(nb % 10); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /C07/ex02/ft_ultimate_range.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ultimate_range.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/08 16:35:24 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/09 13:23:08 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_ultimate_range(int **range, int min, int max) 16 | { 17 | int size; 18 | int i; 19 | int *poin; 20 | 21 | size = max - min; 22 | if (min >= max) 23 | { 24 | *range = 0; 25 | return (0); 26 | } 27 | poin = (int *) malloc(size * sizeof(int)); 28 | if (!poin) 29 | { 30 | range = 0; 31 | return (-1); 32 | } 33 | *range = poin; 34 | i = 0; 35 | while (i < size) 36 | { 37 | poin[i] = min + i; 38 | i++; 39 | } 40 | return (size); 41 | } 42 | -------------------------------------------------------------------------------- /C09/ex01/Makefile: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # Makefile :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: ostouayr +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2024/07/17 18:41:49 by ostouayr #+# #+# # 9 | # Updated: 2024/07/17 20:07:13 by ostouayr ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | FILES_C = srcs/ft_putchar.c srcs/ft_swap.c srcs/ft_putstr.c srcs/ft_strlen.c srcs/ft_strcmp.c 14 | FILES_O = srcs/ft_putchar.o srcs/ft_swap.o srcs/ft_putstr.o srcs/ft_strlen.o srcs/ft_strcmp.o 15 | CC_CFLAGS = cc -Wall -Wextra -Werror -c 16 | NAME = libft.a 17 | AR = ar rcs 18 | RM = rm -f 19 | MV = mv *.o srcs 20 | 21 | all: 22 | $(CC_CFLAGS) $(FILES_C) 23 | $(MV) 24 | $(AR) $(NAME) $(FILES_O) 25 | 26 | clean: 27 | $(RM) $(FILES_O) 28 | 29 | fclean: clean 30 | $(RM) $(NAME) 31 | 32 | re: fclean all 33 | 34 | .PHONY: all clean fclean re 35 | -------------------------------------------------------------------------------- /C04/ex03/ft_atoi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atoi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/03 11:30:37 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/03 14:12:30 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_atoi(char *str) 14 | { 15 | int i; 16 | int sign; 17 | int count; 18 | int convert; 19 | 20 | i = 0; 21 | sign = 1; 22 | count = 0; 23 | while (str[i] == ' ' || (str[i] >= 9 && str[i] <= 13)) 24 | i++; 25 | while (str[i] == '+' || str[i] == '-') 26 | { 27 | if (str[i] == '-') 28 | count++; 29 | i++; 30 | } 31 | if (count % 2 == 1) 32 | sign = -1; 33 | convert = 0; 34 | while (str[i] != '\0' && (str[i] >= '0' && str[i] <= '9')) 35 | { 36 | convert = convert * 10 + str[i] - '0'; 37 | i++; 38 | } 39 | return (sign * convert); 40 | } 41 | -------------------------------------------------------------------------------- /C03/ex05/ft_strlcat.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlcat.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/01 21:41:56 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/02 14:30:32 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int ft_strlen(char *str) 14 | { 15 | int i; 16 | 17 | i = 0; 18 | while (str[i]) 19 | i++; 20 | return (i); 21 | } 22 | 23 | unsigned int ft_strlcat(char *dest, char *src, unsigned int size) 24 | { 25 | unsigned int i; 26 | unsigned int j; 27 | unsigned int ld; 28 | unsigned int ls; 29 | 30 | ld = ft_strlen(dest); 31 | ls = ft_strlen(src); 32 | j = 0; 33 | i = ld; 34 | if (ld >= size) 35 | return (ld + ls); 36 | while (i < size -1 && src[j] != '\0') 37 | { 38 | dest[i] = src[j]; 39 | i++; 40 | j++; 41 | } 42 | dest[i] = '\0'; 43 | return (ld + ls); 44 | } 45 | -------------------------------------------------------------------------------- /rush00/rush00.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* rush00.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/29 16:49:02 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/29 22:03:18 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c); 16 | 17 | void rush(int x, int y) 18 | { 19 | int i; 20 | int j; 21 | 22 | i = 0; 23 | while (i < y && (x > 0 && y > 0)) 24 | { 25 | j = 0; 26 | while (j < x) 27 | { 28 | if ((i == 0 && (j == 0 || j == x - 1)) 29 | || (i == y - 1 && (j == 0 || j == x - 1))) 30 | ft_putchar('o'); 31 | else if (i == 0 || i == y - 1) 32 | ft_putchar('-'); 33 | else if (j == 0 || j == x - 1) 34 | ft_putchar('|'); 35 | else 36 | ft_putchar(' '); 37 | j++; 38 | } 39 | ft_putchar('\n'); 40 | i++; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /C00/ex06/ft_print_comb2.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_print_comb2.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/06/27 09:30:53 by ostouayr #+# #+# */ 9 | /* Updated: 2024/06/27 10:11:32 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putchar(char c) 16 | { 17 | write(1, &c, 1); 18 | } 19 | 20 | void ft_print_comb2(void) 21 | { 22 | int number1; 23 | int number2; 24 | 25 | number1 = 0; 26 | while (number1 <= 98) 27 | { 28 | number2 = number1 + 1; 29 | while (number2 <= 99) 30 | { 31 | ft_putchar(number1 / 10 + '0'); 32 | ft_putchar(number1 % 10 + '0'); 33 | ft_putchar(' '); 34 | ft_putchar(number2 / 10 + '0'); 35 | ft_putchar(number2 % 10 + '0'); 36 | if (number1 == 98) 37 | break ; 38 | write(1, ", ", 2); 39 | number2++; 40 | } 41 | number1++; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Exam02/ft_split.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int is_separator(char c) 4 | { 5 | if(c == 9 || c == 10 || c == 32) 6 | { 7 | return(1); 8 | } 9 | if(c == 0) 10 | { 11 | return(1); 12 | } 13 | return(0); 14 | } 15 | int lentosep(char *str) 16 | { 17 | int i = 0; 18 | while(str[i] && !is_separator(str[i])) 19 | i++; 20 | return(i); 21 | } 22 | int countwords(char *str) 23 | { 24 | int i = 0; 25 | int len = 0; 26 | while(str[i]) 27 | { 28 | while(str[i] && is_separator(str[i])) 29 | i++; 30 | if(str[i]) 31 | len++; 32 | while(str[i] && !is_separator(str[i])) 33 | i++; 34 | } 35 | return(len); 36 | } 37 | char *copywords(char *str) 38 | { 39 | int i = 0; 40 | char *word; 41 | int len = lentosep(str); 42 | word = (char *) malloc(sizeof(char) * (len + 1)); 43 | if(!word) 44 | return(0); 45 | while(i < len) 46 | { 47 | word[i] = str[i]; 48 | i++; 49 | } 50 | word[i] = '\0'; 51 | return(word); 52 | } 53 | char **split(char *str) 54 | { 55 | int i = 0; 56 | 57 | int count = countwords(str); 58 | char **strings = malloc(sizeof(char *) * (count + 1)); 59 | if(!strings) 60 | return(0); 61 | while(*str) 62 | { 63 | while(*str && is_separator(*str)) 64 | str++; 65 | if(*str) 66 | { 67 | strings[i] = copywords(str); 68 | i++; 69 | } 70 | while(*str && !is_separator(*str)) 71 | str++; 72 | } 73 | strings[i] = 0; 74 | return(strings); 75 | } 76 | int main() 77 | { 78 | int i = 0; 79 | char str[] = "salam aya ana smit batman"; 80 | char **strings = split(str); 81 | while(strings[i]) 82 | { 83 | printf("%s\n",strings[i]); 84 | i++; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Final-Exam/ft_split.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int is_separator(char c) 4 | { 5 | if(c == 9 || c == 10 || c == 32) 6 | { 7 | return(1); 8 | } 9 | if(c == 0) 10 | { 11 | return(1); 12 | } 13 | return(0); 14 | } 15 | int lentosep(char *str) 16 | { 17 | int i = 0; 18 | while(str[i] && !is_separator(str[i])) 19 | i++; 20 | return(i); 21 | } 22 | int countwords(char *str) 23 | { 24 | int i = 0; 25 | int len = 0; 26 | while(str[i]) 27 | { 28 | while(str[i] && is_separator(str[i])) 29 | i++; 30 | if(str[i]) 31 | len++; 32 | while(str[i] && !is_separator(str[i])) 33 | i++; 34 | } 35 | return(len); 36 | } 37 | char *copywords(char *str) 38 | { 39 | int i = 0; 40 | char *word; 41 | int len = lentosep(str); 42 | word = (char *) malloc(sizeof(char) * (len + 1)); 43 | if(!word) 44 | return(0); 45 | while(i < len) 46 | { 47 | word[i] = str[i]; 48 | i++; 49 | } 50 | word[i] = '\0'; 51 | return(word); 52 | } 53 | char **split(char *str) 54 | { 55 | int i = 0; 56 | 57 | int count = countwords(str); 58 | char **strings = malloc(sizeof(char *) * (count + 1)); 59 | if(!strings) 60 | return(0); 61 | while(*str) 62 | { 63 | while(*str && is_separator(*str)) 64 | str++; 65 | if(*str) 66 | { 67 | strings[i] = copywords(str); 68 | i++; 69 | } 70 | while(*str && !is_separator(*str)) 71 | str++; 72 | } 73 | strings[i] = 0; 74 | return(strings); 75 | } 76 | int main() 77 | { 78 | int i = 0; 79 | char str[] = "salam aya ana smit batman"; 80 | char **strings = split(str); 81 | while(strings[i]) 82 | { 83 | printf("%s\n",strings[i]); 84 | i++; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /C06/ex03/ft_sort_params.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sort_params.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/07 22:11:46 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/08 09:37:21 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strcmp(char *s1, char *s2) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (s1[i] != '\0' && s2[i] != '\0' && s1[i] == s2[i]) 21 | { 22 | i++; 23 | } 24 | return (s1[i] - s2[i]); 25 | } 26 | 27 | void ft_swap(char **a, char **b) 28 | { 29 | char *temp; 30 | 31 | temp = *a; 32 | *a = *b; 33 | *b = temp; 34 | } 35 | 36 | int main(int ac, char **av) 37 | { 38 | int i; 39 | int j; 40 | 41 | i = 1; 42 | while (i < ac -1) 43 | { 44 | if (ft_strcmp(av[i], av[i + 1]) > 0) 45 | { 46 | ft_swap(&av[i], &av[i + 1]); 47 | i = 0; 48 | } 49 | i++; 50 | } 51 | i = 1; 52 | while (i < ac) 53 | { 54 | j = 0; 55 | while (av[i][j]) 56 | { 57 | write(1, &av[i][j++], 1); 58 | } 59 | write(1, "\n", 1); 60 | i++; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /C08/ex05/ft_show_tab.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_show_tab.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/15 09:42:40 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/15 18:12:25 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft_stock_str.h" 14 | #include 15 | 16 | void ft_putchar(char c) 17 | { 18 | write(1, &c, 1); 19 | } 20 | 21 | void ft_putstr(char *str) 22 | { 23 | int i; 24 | 25 | i = 0; 26 | while (str[i]) 27 | { 28 | write(1, &str[i], 1); 29 | i++; 30 | } 31 | } 32 | 33 | void ft_putnbr(int nb) 34 | { 35 | if (nb == -2147483648) 36 | { 37 | write(1, "-2147483648", 11); 38 | } 39 | else if (nb < 0) 40 | { 41 | nb *= -1; 42 | ft_putchar('-'); 43 | ft_putnbr(nb); 44 | } 45 | else if (nb < 10) 46 | { 47 | ft_putchar(nb + '0'); 48 | } 49 | else 50 | { 51 | ft_putnbr(nb / 10); 52 | ft_putnbr(nb % 10); 53 | } 54 | } 55 | 56 | void ft_show_tab(struct s_stock_str *par) 57 | { 58 | int i; 59 | 60 | i = 0; 61 | while (par[i].str) 62 | { 63 | ft_putstr(par[i].str); 64 | ft_putchar('\n'); 65 | ft_putnbr(par[i].size); 66 | ft_putchar('\n'); 67 | ft_putstr(par[i].copy); 68 | ft_putchar('\n'); 69 | i++; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /C08/ex04/ft_strs_to_tab.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strs_to_tab.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/14 16:38:45 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/15 17:40:52 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft_stock_str.h" 14 | #include 15 | 16 | int ft_strlen(char *str) 17 | { 18 | int i; 19 | 20 | i = 0; 21 | while (str[i]) 22 | { 23 | i++; 24 | } 25 | return (i); 26 | } 27 | 28 | char *ft_strdup(char *src) 29 | { 30 | int i; 31 | char *dup; 32 | int srclen; 33 | 34 | srclen = ft_strlen(src); 35 | dup = malloc(srclen * sizeof(char) + 1); 36 | if (!dup) 37 | { 38 | return (0); 39 | } 40 | i = 0; 41 | while (src[i]) 42 | { 43 | dup[i] = src[i]; 44 | i++; 45 | } 46 | dup[i] = '\0'; 47 | return (dup); 48 | } 49 | 50 | struct s_stock_str *ft_strs_to_tab(int ac, char **av) 51 | { 52 | struct s_stock_str *struct_arr; 53 | int i; 54 | 55 | struct_arr = malloc(sizeof(struct s_stock_str) * (ac + 1)); 56 | if (!struct_arr) 57 | return (0); 58 | i = 0; 59 | while (i < ac) 60 | { 61 | struct_arr[i].str = av[i]; 62 | struct_arr[i].size = ft_strlen(av[i]); 63 | struct_arr[i].copy = ft_strdup(av[i]); 64 | i++; 65 | } 66 | struct_arr[i].str = 0; 67 | return (struct_arr); 68 | } 69 | -------------------------------------------------------------------------------- /shell00/ex01/testShell00.tar: -------------------------------------------------------------------------------- 1 | testShell00000455 307765 010175 00000000050 14626721670 015164 0ustar00ostouayrcandidates000000 000000 0000000000000000000000000000000000000000 -------------------------------------------------------------------------------- /C07/ex03/ft_strjoin.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strjoin.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/09 09:30:03 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/09 13:16:18 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | i++; 22 | return (i); 23 | } 24 | 25 | char *ft_strcat(char *dest, char *src) 26 | { 27 | int i; 28 | int j; 29 | 30 | i = 0; 31 | j = 0; 32 | while (dest[i]) 33 | i++; 34 | while (src[j]) 35 | { 36 | dest[i] = src[j]; 37 | i++; 38 | j++; 39 | } 40 | dest[i] = '\0'; 41 | return (dest); 42 | } 43 | 44 | int count_all(int size, char **strs, char *sep) 45 | { 46 | int total; 47 | int sep_len; 48 | int j; 49 | 50 | sep_len = ft_strlen(sep); 51 | j = 0; 52 | while (j < size) 53 | { 54 | total = ft_strlen(strs[j]); 55 | if (j < size -1) 56 | total += sep_len; 57 | j++; 58 | } 59 | return (total); 60 | } 61 | 62 | char *ft_strjoin(int size, char **strs, char *sep) 63 | { 64 | int i; 65 | int j; 66 | char 67 | *join; 68 | 69 | j = 0; 70 | j = count_all(size, strs, sep); 71 | join = malloc(j * sizeof(char) + 1); 72 | if (!join) 73 | return (0); 74 | join[0] = '\0'; 75 | i = 0; 76 | while (i < size) 77 | { 78 | join = ft_strcat(join, strs[i]); 79 | if (i < size - 1) 80 | join = ft_strcat(join, sep); 81 | i++; 82 | } 83 | return (join); 84 | } 85 | -------------------------------------------------------------------------------- /C04/ex04/ft_putnbr_base.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putnbr_base.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/03 19:55:56 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/04 11:33:30 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | { 22 | i++; 23 | } 24 | return (i); 25 | } 26 | 27 | void ft_putchar(char c) 28 | { 29 | write(1, &c, 1); 30 | } 31 | 32 | int is_okey(char *str) 33 | { 34 | int i; 35 | int j; 36 | int k; 37 | 38 | j = ft_strlen(str); 39 | i = 0; 40 | if (str[0] == '\0' || j == 1) 41 | return (0); 42 | while (str[i]) 43 | { 44 | if (str[i] <= 32 || str[i] == 127 || str[i] == '-' || str[i] == '+') 45 | return (0); 46 | k = i + 1; 47 | while (k < ft_strlen(str)) 48 | { 49 | if (str[i] == str[k]) 50 | { 51 | return (0); 52 | } 53 | k++; 54 | } 55 | i++; 56 | } 57 | return (1); 58 | } 59 | 60 | void ft_putnbr_base(int nbr, char *base) 61 | { 62 | int check; 63 | int len; 64 | long 65 | num; 66 | 67 | check = is_okey(base); 68 | len = ft_strlen(base); 69 | num = nbr; 70 | if (check == 1) 71 | { 72 | if (num < 0) 73 | { 74 | ft_putchar('-'); 75 | num *= -1; 76 | } 77 | if (num <= len) 78 | { 79 | ft_putchar(base[num]); 80 | } 81 | if (num >= len) 82 | { 83 | ft_putnbr_base(num / len, base); 84 | ft_putnbr_base(num % len, base); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /C09/ex02/ft_split.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_split.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ostouayr +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/07/17 09:46:34 by ostouayr #+# #+# */ 9 | /* Updated: 2024/07/17 17:44:54 by ostouayr ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int checksep(char c, char *charset) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (charset[i]) 21 | { 22 | if (c == charset[i]) 23 | { 24 | return (1); 25 | } 26 | i++; 27 | } 28 | return (0); 29 | } 30 | 31 | int count_words(char *str, char *charset) 32 | { 33 | int i; 34 | int len; 35 | 36 | i = 0; 37 | len = 0; 38 | while (str[i] != '\0') 39 | { 40 | while (str[i] != '\0' && checksep(str[i], charset)) 41 | i++; 42 | if (str[i] != '\0') 43 | { 44 | len++; 45 | } 46 | while (str[i] != '\0' && !checksep(str[i], charset)) 47 | i++; 48 | } 49 | return (len); 50 | } 51 | 52 | int lentosep(char *str, char *charset) 53 | { 54 | int i; 55 | 56 | i = 0; 57 | while (str[i] != '\0' && !checksep(str[i], charset)) 58 | { 59 | i++; 60 | } 61 | return (i); 62 | } 63 | 64 | char *copy_word(char *str, char *charset) 65 | { 66 | int i; 67 | int len; 68 | char *word; 69 | 70 | i = 0; 71 | len = lentosep(str, charset); 72 | word = (char *)malloc(sizeof(char) * (len + 1)); 73 | if (!word) 74 | return (NULL); 75 | while (i < len) 76 | { 77 | word[i] = str[i]; 78 | i++; 79 | } 80 | word[i] = '\0'; 81 | return (word); 82 | } 83 | 84 | char **ft_split(char *str, char *charset) 85 | { 86 | int i; 87 | char **result; 88 | int len; 89 | int j; 90 | 91 | i = 0; 92 | j = 0; 93 | len = count_words(str, charset); 94 | result = (char **)malloc(sizeof(char *) * (len + 1)); 95 | if (!result) 96 | return (0); 97 | while (*str != '\0') 98 | { 99 | while (*str != '\0' && checksep(*str, charset)) 100 | str++; 101 | if (*str != '\0') 102 | { 103 | result[j] = copy_word(str, charset); 104 | j++; 105 | } 106 | while (*str != '\0' && !checksep(*str, charset)) 107 | str++; 108 | } 109 | result[j] = 0; 110 | return (result); 111 | } 112 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 1337 Piscine - Complete C Programming Journey 🏊‍♂️ 2 | 3 | ## Description 4 | This repository contains my complete journey through the **1337 Piscine** (42 Network Coding School). A comprehensive collection of C programming exercises, exams, and projects completed during the intensive one-month coding bootcamp. 5 | 6 | ## 🎯 What is 1337 Piscine? 7 | The 1337 Piscine is an intensive 4-week coding bootcamp at 1337 Coding School (part of the 42 Network). It's designed to teach fundamental programming concepts through: 8 | - **100% Peer-to-Peer Learning** - No traditional teachers 9 | - **Project-Based Learning** - Every exercise is a mini-project 10 | - **Collaborative Problem Solving** - Students help each other grow 11 | - **Rigorous Testing** - Weekly exams and practical challenges 12 | 13 | ## 📚 Repository Structure 14 | 15 | ### Core Modules (C00-C09) 16 | - **[C00](C00/)** - Introduction to C, basic I/O functions 17 | - **[C01](C01/)** - Pointers and memory addresses 18 | - **[C02](C02/)** - String manipulation and arrays 19 | - **[C03](C03/)** - String comparison and concatenation functions 20 | - **[C04](C04/)** - String utilities and number conversion 21 | - **[C05](C05/)** - Mathematical functions and recursion 22 | - **[C06](C06/)** - Command line arguments handling 23 | - **[C07](C07/)** - Dynamic memory allocation 24 | - **[C08](C08/)** - Header files and structures 25 | - **[C09](C09/)** - Advanced string splitting and library creation 26 | 27 | ### Practical Assessments 28 | - **[Exam00](Exam00/)** - Basic C syntax and simple programs 29 | - **[Exam01](Exam01/)** - String manipulation challenges 30 | - **[Exam02](Exam02/)** - Advanced string processing 31 | - **[Final-Exam](Final-Exam/)** - Comprehensive 8-hour coding challenge 32 | 33 | ### Special Projects 34 | - **[rush00](rush00/)** - Weekend team project - ASCII pattern generator 35 | - **[shell00](shell00/)** - Unix shell and command line basics 36 | - **[shell01](shell01/)** - Advanced shell scripting 37 | 38 | ## 🛠️ Key Skills Developed 39 | 40 | ### Programming Fundamentals 41 | - **C Language Mastery** - Syntax, data types, control structures 42 | - **Memory Management** - Pointers, malloc, free 43 | - **String Processing** - Custom string functions implementation 44 | - **Algorithm Design** - Problem-solving and optimization 45 | 46 | ### Software Engineering Practices 47 | - **Code Quality** - Following 42 Norm coding standards 48 | - **Testing** - Manual testing and edge case handling 49 | - **Documentation** - Clean, readable code structure 50 | - **Collaboration** - Peer review and pair programming 51 | 52 | ## 🎯 Notable Implementations 53 | 54 | ### Custom String Functions 55 | - [`ft_strlen`](C04/ex00/ft_strlen.c) - String length calculation 56 | - [`ft_putstr`](C01/ex05/ft_putstr.c) - String output function 57 | - [`ft_strdup`](C07/ex00/ft_strdup.c) - String duplication with malloc 58 | - [`ft_strncat`](C03/ex03/ft_strncat.c) - String concatenation 59 | 60 | ### Advanced Projects 61 | - [`ft_split`](C09/ex02/ft_split.c) - String splitting function 62 | - [`wdmatch`](Exam02/wdmatch.c) - Word matching algorithm 63 | - [`last_word`](Exam02/last_word.c) - Extract last word from string 64 | 65 | ## 🏆 Exam Challenges 66 | 67 | ### Exam Structure 68 | Each exam consisted of: 69 | - **4-hour time limit** (8 hours for final) 70 | - **No external resources** - No internet, no documentation 71 | - **Gradual difficulty** - From basic syntax to complex algorithms 72 | - **Real-time evaluation** - Immediate feedback system 73 | 74 | ### Sample Problems 75 | - **Hello World variations** - Basic output formatting 76 | - **String manipulation** - Reverse, capitalize, extract 77 | - **Pattern matching** - Algorithm implementation 78 | - **Memory management** - Dynamic allocation challenges 79 | 80 | ## 🚀 Technologies & Tools 81 | 82 | - **Language**: C Programming 83 | - **Compiler**: GCC with strict flags 84 | - **Standards**: 42 School Norm 85 | - **Testing**: Manual testing and peer evaluation 86 | - **Version Control**: Git workflow 87 | 88 | ## 📈 Learning Outcomes 89 | 90 | After completing the 1337 Piscine, I gained: 91 | - **Solid C Programming Foundation** - From basics to advanced concepts 92 | - **Problem-Solving Skills** - Breaking down complex problems 93 | - **Code Quality Awareness** - Writing clean, efficient code 94 | - **Collaborative Learning** - Peer-to-peer knowledge sharing 95 | - **Stress Management** - Working under pressure with tight deadlines 96 | 97 | ## 🎓 Certification 98 | Successfully completed the 1337 Piscine program at 42 Network Coding School 99 | 100 | ## ⚠️ Academic Integrity Notice 101 | This repository is shared for educational and portfolio purposes. If you're currently a 1337/42 student: 102 | - **Don't copy-paste** - Write your own code 103 | - **Use for reference only** - Understand the logic first 104 | - **Follow the learning process** - The journey is more important than the destination 105 | -------------------------------------------------------------------------------- /shell00/ex02/exo2.tar: -------------------------------------------------------------------------------- 1 | test0/000715 307765 010175 00000000000 14626675264 014201 5ustar00ostouayrcandidates000000 000000 test1000714 307765 010175 00000000004 14626704210 014101 0ustar00ostouayrcandidates000000 000000 1234test2/000504 307765 010175 00000000000 14626713134 014164 5ustar00ostouayrcandidates000000 000000 test3000404 307765 010175 00000000001 14626722060 014077 0ustar00ostouayrcandidates000000 000000 1test4000641 307765 010175 00000000002 14626721764 014116 0ustar00ostouayrcandidates000000 000000 12test5000404 307765 010175 00000000000 14626722060 015064 1test3ustar00ostouayrcandidates000000 000000 test6000777 307765 010175 00000000000 14626710200 015071 2test0ustar00ostouayrcandidates000000 000000 --------------------------------------------------------------------------------