├── 0x00-hello_world ├── 0-preprocessor ├── 1-compiler ├── 100-intel ├── 101-quote.c ├── 2-assembler ├── 3-name ├── 4-puts.c ├── 5-printf.c ├── 6-size.c ├── README.md ├── git └── new ├── 0x01-variables_if_else_while ├── 0-positive_or_negative.c ├── 1-last_digit.c ├── 2-print_alphabet.c ├── 3-print_alphabets.c ├── 4-print_alphabt.c ├── 5-print_numbers.c ├── 6-print_numberz.c ├── 7-print_tebahpla.c ├── 8-print_base16.c ├── 9-print_comb.c ├── README.md ├── git └── new ├── 0x02-functions_nested_loops ├── 0-putchar.c ├── 1-alphabet.c ├── 10-add.c ├── 100-times_table.c ├── 101-natural.c ├── 102-fibonacci.c ├── 103-fibonacci.c ├── 104-fibonacci.c ├── 11-print_to_98.c ├── 2-print_alphabet_x10.c ├── 3-islower.c ├── 4-isalpha.c ├── 5-sign.c ├── 6-abs.c ├── 7-print_last_digit.c ├── 8-24_hours.c ├── 9-fizz_buzz.c ├── 9-times_table.c ├── README.md └── main.h ├── 0x03-debugging ├── 0-main.c ├── 1-main.c ├── README.md ├── git ├── main.h └── new ├── 0x04-more_functions_nested_loops ├── .5-more_numbers.c.swp ├── 0-isupper.c ├── 1-isdigit.c ├── 2-mul.c ├── 3-print_numbers.c ├── 4-print_most_numbers.c ├── README.md ├── git ├── main.h └── new ├── 0x05-pointers_arrays_strings ├── 0-reset_to_98.c ├── 1-swap.c ├── 100-atoi.c ├── 101-keygen.c ├── 2-strlen.c ├── 3-puts.c ├── 4-print_rev.c ├── 5-rev_string.c ├── 6-puts2.c ├── 7-puts_half.c ├── 8-print_array.c ├── 9-strcpy.c ├── README.md └── main.h ├── 0x06-pointers_arrays_strings ├── 0-strcat.c ├── 1-strncat.c ├── 100-rot13.c ├── 101-print_number.c ├── 102-magic.c ├── 103-infinite_add.c ├── 104-print_buffer.c ├── 2-strncpy.c ├── 3-strcmp.c ├── 4-rev_array.c ├── 5-string_toupper.c ├── 6-cap_string.c ├── 7-leet.c ├── README.md └── main.h ├── 0x07-pointers_arrays_strings ├── 0-memset.c ├── 1-memcpy.c ├── 100-set_string.c ├── 101-crackme_password ├── 2-strchr.c ├── 3-strspn.c ├── 4-strpbrk.c ├── 5-strstr.c ├── 7-print_chessboard.c ├── 8-print_diagsums.c ├── README.md ├── git ├── main.h └── new ├── 0x08-recursion ├── 0-puts_recursion.c ├── 1-print_rev_recursion.c ├── 100-is_palindrome.c ├── 101-wildcmp.c ├── 2-strlen_recursion.c ├── 3-factorial.c ├── 4-pow_recursion.c ├── 5-sqrt_recursion.c ├── 6-is_prime_number.c ├── README.md └── main.h ├── 0x09-static_libraries ├── README.md ├── create_static_lib.sh └── main.h └── README.md /0x00-hello_world/0-preprocessor: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -E $CFILE -o c 3 | -------------------------------------------------------------------------------- /0x00-hello_world/1-compiler: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -c $CFILE 3 | -------------------------------------------------------------------------------- /0x00-hello_world/100-intel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -S -masm=intel $CFILE 3 | -------------------------------------------------------------------------------- /0x00-hello_world/101-quote.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /** 4 | * main-Entry point 5 | * 6 | * Return: Always 1 (success). 7 | */ 8 | int main(void) 9 | { 10 | write(2, "and that piece of art is useful\" - Dora Korpar, 2015-10-19\n", 59); 11 | return (1); 12 | } 13 | -------------------------------------------------------------------------------- /0x00-hello_world/2-assembler: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -S $CFILE 3 | -------------------------------------------------------------------------------- /0x00-hello_world/3-name: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc $CFILE -o cisfun 3 | -------------------------------------------------------------------------------- /0x00-hello_world/4-puts.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | *main- A program that uses puts to print a string 4 | *Return: ends with 0 5 | */ 6 | int main(void) 7 | { 8 | puts("\"Programming is like building a multilingual puzzle"); 9 | return (0); 10 | } 11 | -------------------------------------------------------------------------------- /0x00-hello_world/5-printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | * main- prints a string followed by a new line 4 | * Return: 0 5 | */ 6 | int main(void) 7 | { 8 | printf("with proper grammar, but the outcome is a piece of art,\n"); 9 | return (0); 10 | } 11 | -------------------------------------------------------------------------------- /0x00-hello_world/6-size.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | * main- c program that prints the size of some computer types 4 | * Return: 0 5 | */ 6 | int main(void) 7 | { 8 | printf("Size of a char: %ld byte(s)\n", sizeof(char)); 9 | printf("Size of an int: %ld byte(s)\n", sizeof(int)); 10 | printf("Size of a long int: %ld byte(s)\n", sizeof(long int)); 11 | printf("Size of a long long int: %ld byte(s)\n", sizeof(long long int)); 12 | printf("Size of a float: %ld byte(s)\n", sizeof(float)); 13 | return (0); 14 | } 15 | -------------------------------------------------------------------------------- /0x00-hello_world/README.md: -------------------------------------------------------------------------------- 1 | A new project to learn and practice c programming language 2 | -------------------------------------------------------------------------------- /0x00-hello_world/git: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git add . 3 | read -p 'Commit message: ' message 4 | git commit -m $message 5 | git push 6 | -------------------------------------------------------------------------------- /0x00-hello_world/new: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read -p "File name: " name 3 | chmod u+x $name 4 | vi $name 5 | git add $name 6 | read -p 'Commit message: ' message 7 | git commit -m $message 8 | git push 9 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/0-positive_or_negative.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /** 6 | * main - Generate a random number and determine if it 7 | * is positive, negative, or zero 8 | * 9 | * This function generates a random number using the 10 | * rand() function seeded with the current time. 11 | * It then checks whether the number is positive, 12 | * negative, or zero, and outputs the corresponding 13 | * string value to the console. 14 | * 15 | * Return: Always 0. 16 | */ 17 | 18 | int main(void) 19 | { 20 | int n; 21 | srand(time(0)); 22 | n = rand() - RAND_MAX / 2; 23 | if (n > 0) 24 | { 25 | printf("%d is positive\n", n); 26 | } 27 | else if (n == 0) 28 | { 29 | printf("%d is zero\n", n); 30 | } 31 | else 32 | { 33 | printf("%d is negative\n", n); 34 | } 35 | return (0); 36 | } 37 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/1-last_digit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /** 6 | * main - Entry point of the program 7 | * 8 | * Description: The main function generates a random 9 | * number and 10 | * computes the last digit to output the corresponding 11 | * string. 12 | * 13 | * Return: Always 0 (success) 14 | */ 15 | 16 | int main(void) 17 | { 18 | int n; 19 | int lastdigit; 20 | srand(time(0)); 21 | n = rand() - RAND_MAX / 2; 22 | 23 | lastdigit = n % 10; 24 | 25 | if (lastdigit > 5) 26 | { 27 | printf("Last digit of %d is %d and is greater 28 | than 5\n", n, lastdigit); 29 | } 30 | else if (lastdigit == 0) 31 | { 32 | printf("Last digit of %d is %d and is 0\n", n, 33 | lastdigit); 34 | } 35 | else 36 | { 37 | printf("Last digit of %d is %d and is less 38 | than 6 and not 0\n", n, 39 | lastdigit); 40 | } 41 | return (0); 42 | } 43 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/2-print_alphabet.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Return: Always 0 (success) 7 | */ 8 | 9 | int main(void) 10 | { 11 | char c; 12 | 13 | for (c = 'a'; c <= 'z'; c++) 14 | 15 | putchar(c); 16 | putchar('\n'); 17 | return (0); 18 | } 19 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/3-print_alphabets.c: -------------------------------------------------------------------------------- 1 | #include 2 | /** 3 | * main - Entry point 4 | * 5 | * Return: always 0 (success) 6 | */ 7 | 8 | int main(void) 9 | { 10 | char c; 11 | 12 | for (c = 'a'; c <= 'z'; c++) 13 | 14 | putchar(c); 15 | 16 | for (c = 'A'; c <= 'Z'; c++) 17 | 18 | putchar(c); 19 | putchar('\n'); 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/4-print_alphabt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Return: Always 0 (success) 7 | */ 8 | 9 | int main(void) 10 | { 11 | char letter; 12 | 13 | for (letter = 'a'; letter <= 'z'; letter++) 14 | 15 | { 16 | if (letter == 'e' || letter == 'q') 17 | { 18 | continue; 19 | } 20 | putchar(letter); 21 | } 22 | putchar('\n'); 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/5-print_numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Return: Always 0. 7 | */ 8 | 9 | int main(void) 10 | { 11 | int i; 12 | 13 | for (i = 0; i < 10; i++) 14 | { 15 | printf("%d", i); 16 | } 17 | printf("\n"); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/6-print_numberz.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Return: Always 0. 7 | */ 8 | 9 | int main(void) 10 | { 11 | int i; 12 | 13 | for (i = 0; i < 10; i++) 14 | { 15 | putchar(i + '0'); 16 | } 17 | putchar('\n'); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/7-print_tebahpla.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * print the alphabet in reverse order lowercase 7 | * 8 | * Return: Always 0. 9 | */ 10 | 11 | int main(void) 12 | { 13 | char c; 14 | 15 | for (c = 'z'; c >= 'a'; c--) 16 | { 17 | putchar(c); 18 | } 19 | putchar('\n'); 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/8-print_base16.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Prints all the numbers in base 16; 7 | * Return: Always 0. 8 | */ 9 | 10 | int main(void) 11 | { 12 | int i; 13 | char c; 14 | 15 | for (i = 0; i < 16; i++) 16 | { 17 | if (i < 10) 18 | { 19 | c = i + '0'; 20 | } 21 | else 22 | { 23 | c = i - 10 + 'a'; 24 | } 25 | putchar(c); 26 | } 27 | putchar('\n'); 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/9-print_comb.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main -Entry point 5 | * 6 | * prints all possible combination of single numbers 7 | * Return: Always 0. 8 | */ 9 | 10 | int main(void) 11 | { 12 | int i; 13 | 14 | for (i = 0; i < 10; i++) 15 | { 16 | putchar(i + '0'); 17 | if (i < 9) 18 | { 19 | putchar(','); 20 | putchar(' '); 21 | } 22 | else 23 | { 24 | putchar('\n'); 25 | } 26 | } 27 | return (0); 28 | } 29 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/README.md: -------------------------------------------------------------------------------- 1 | Practicing conditional statements on C programming language 2 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/git: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git add . 3 | read -p 'Commit message: ' message 4 | git commit -m $message 5 | git push 6 | -------------------------------------------------------------------------------- /0x01-variables_if_else_while/new: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read -p "File name: " name 3 | chmod u+x $name 4 | vi $name 5 | git add $name 6 | read -p 'Commit message: ' message 7 | git commit -m $message 8 | git push 9 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/0-putchar.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Return: Always 0. 7 | * 8 | */ 9 | 10 | int main(void) 11 | { 12 | _putchar('_'); 13 | _putchar('p'); 14 | _putchar('u'); 15 | _putchar('t'); 16 | _putchar('c'); 17 | _putchar('h'); 18 | _putchar('a'); 19 | _putchar('r'); 20 | _putchar('\n'); 21 | return (0); 22 | } 23 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/1-alphabet.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_alphabet - Entry point ,this prints alphabet 5 | * in lowercase 6 | * 7 | * Return: Always 0. 8 | */ 9 | 10 | void print_alphabet(void) 11 | { 12 | char alpha; 13 | 14 | for (alpha = 'a'; alpha <= 'z'; alpha++) 15 | _putchar(alpha); 16 | 17 | _putchar('\n'); 18 | } 19 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/10-add.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * add - adds two numbers 5 | * @num1: first number to be added 6 | * @num2: second number to be added 7 | * 8 | * Return: addition result 9 | */ 10 | 11 | int add(int num1, int num2) 12 | { 13 | return (num1 + num2); 14 | } 15 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/100-times_table.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_times_table - Prints the n times table 5 | * 6 | * @n: number times table (0 < n <= 15) 7 | * 8 | * Return: no return 9 | */ 10 | 11 | void print_times_table(int n) 12 | { 13 | int a, b, op; 14 | 15 | if (n >= 0 && n <= 15) 16 | { 17 | for (a = 0; a <= n; a++) 18 | { 19 | _putchar(48); 20 | for (b = 1; b <= n; b++) 21 | { 22 | op = a * b; 23 | _putchar(44); 24 | _putchar(32); 25 | if (op <= 9) 26 | { 27 | _putchar(32); 28 | _putchar(32); 29 | _putchar(op + 48); 30 | } 31 | else if (op <= 99) 32 | { 33 | _putchar(32); 34 | _putchar((op / 10) + 48); 35 | _putchar((op % 10) + 48); 36 | } 37 | else 38 | { 39 | _putchar(((op / 100) % 10) + 48); 40 | _putchar(((op / 10) % 10) + 48); 41 | _putchar((op % 10) + 48); 42 | } 43 | } 44 | _putchar('\n'); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/101-natural.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Prints natural numbers below 1024 that are 5 | * multiplies of 3 or 5 6 | * 7 | * Return: Always 0. 8 | */ 9 | 10 | int main(void) 11 | { 12 | int a, b; 13 | 14 | for (a = 1; a < 1024; a++) 15 | { 16 | if ((a % 3) == 0 || (a % 5) == 0) 17 | b += a; 18 | } 19 | printf("%d\n", b); 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/102-fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Prints the add of the Fibonacci numbers 5 | * 6 | * Return: Always 0. 7 | */ 8 | 9 | int main(void) 10 | { 11 | int c; 12 | long int n1, n2, fn; 13 | 14 | n1 = 1; 15 | n2 = 2; 16 | 17 | printf("%ld, %ld", n1, n2); 18 | for (c = 0; c < 48; c++) 19 | { 20 | fn = n1 + n2; 21 | printf(", %ld", fn); 22 | n1 = n2; 23 | n2 = fn; 24 | } 25 | printf("\n"); 26 | return (0); 27 | } 28 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/103-fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Prints the add of the even-valued 5 | * fibonacci numbers. 6 | * 7 | * Return: Always 0. 8 | */ 9 | 10 | int main(void) 11 | { 12 | long int n1, n2, fn, afn; 13 | 14 | n1 = 1; 15 | n2 = 2; 16 | fn = afn = 0; 17 | while (fn <= 4000000) 18 | { 19 | fn = n1 + n2; 20 | n1 = n2; 21 | n2 = fn; 22 | if ((n1 % 2) == 0) 23 | { 24 | afn += n1; 25 | } 26 | } 27 | printf("%ld\n", afn); 28 | return (0); 29 | } 30 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/104-fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Prints the first 98 Fibonacci numbers 5 | * 6 | * Return: Always 0. 7 | */ 8 | 9 | int main(void) 10 | { 11 | int c, boolean, boolean2; 12 | long int n1, n2, fn, fn2, n11, n22; 13 | 14 | n1 = 1; 15 | n2 = 2; 16 | boolean = boolean2 = 1; 17 | printf("%ld, %ld", n1, n2); 18 | for (c = 0; c < 96; c++) 19 | { 20 | if (boolean) 21 | { 22 | fn = n1 + n2; 23 | printf(", %ld", fn); 24 | n1 = n2; 25 | n2 = fn; 26 | } 27 | else 28 | { 29 | if (boolean2) 30 | { 31 | n11 = n1 % 1000000000; 32 | n22 = n2 % 1000000000; 33 | n1 = n1 / 1000000000; 34 | n2 = n2 / 1000000000; 35 | boolean2 = 0; 36 | } 37 | fn2 = (n11 + n22); 38 | fn = n1 + n2 + (fn2 / 1000000000); 39 | printf(", %ld", fn); 40 | printf("%ld", fn2 % 1000000000); 41 | n1 = n2; 42 | n11 = n22; 43 | n2 = fn; 44 | n22 = (fn2 % 1000000000); 45 | } 46 | if (((n1 + n2) < 0) && boolean == 1) 47 | boolean = 0; 48 | } 49 | printf("\n"); 50 | return (0); 51 | } 52 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/11-print_to_98.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * print_to_98 - prints all natural numbers from 5 | * input to 98 6 | * 7 | * @k: the nunber to start counting from 8 | */ 9 | 10 | void print_to_98(int k) 11 | { 12 | if (k >= 98) 13 | { 14 | while (k > 98) 15 | printf("%d, ", k--); 16 | printf("%d\n", k); 17 | } 18 | else 19 | { 20 | while (k < 98) 21 | printf("%d, ", k++); 22 | printf("%d\n", k); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/2-print_alphabet_x10.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_alphabet_x10 - prints lowercase alphabets in 5 | * a row 10 times. 6 | * 7 | * Return: 0. 8 | */ 9 | 10 | void print_alphabet_x10(void) 11 | { 12 | int count = 1; 13 | char alpha; 14 | 15 | while (count++ <= 10) 16 | { 17 | for (alpha = 'a'; alpha <= 'z'; alpha++) 18 | _putchar(alpha); 19 | 20 | _putchar('\n'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/3-islower.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _islower - checks if input alphabet(in this example 5 | * letter c). 6 | * @c: the letter being checked 7 | * 8 | * Return: 1 if lowercase, else 0. 9 | */ 10 | 11 | int _islower(int c) 12 | { 13 | if (c >= 'a' && c <= 'z') 14 | return (1); 15 | else 16 | return (0); 17 | } 18 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/4-isalpha.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _isalpha - checks if the character is alpha 5 | * @c: letter to be checked 6 | * 7 | * Return: 1 if its alphabet ,else 0. 8 | */ 9 | 10 | int _isalpha(int c) 11 | { 12 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'z')) 13 | return (1); 14 | else 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/5-sign.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_sign - prints the sign of a number 5 | * @k: the nunber to be chevked for sign 6 | * 7 | * Return: 1 if sign is positive 8 | * 0 if sign is zero 9 | * -1 if sign is negative 10 | */ 11 | 12 | int print_sign(int k) 13 | { 14 | if (k > 0) 15 | { 16 | _putchar('+'); 17 | return (1); 18 | } 19 | else if (k == 0) 20 | { 21 | _putchar('0'); 22 | return (0); 23 | } 24 | else 25 | { 26 | _putchar('-'); 27 | return (-1); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/6-abs.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _abs - estimates the absolute value of a number 5 | * @k: the number to be checked 6 | * Return: the absolute value or estimate of the 7 | * number 8 | */ 9 | 10 | int _abs(int k) 11 | { 12 | if (k >= 0) 13 | return (k); 14 | else 15 | return (-k); 16 | } 17 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/7-print_last_digit.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_last_digit - prints last digit of a number 5 | * @k: the number 6 | * 7 | * Return: the last digit of the number 8 | */ 9 | 10 | int print_last_digit(int k) 11 | { 12 | int last_digit; 13 | 14 | last_digit = k % 10; 15 | 16 | if (last_digit < 0) 17 | last_digit *= -1; 18 | 19 | _putchar(last_digit + '0'); 20 | 21 | 22 | return (last_digit); 23 | } 24 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/8-24_hours.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * jack_bauer - prints every minute of jack bauer 5 | * starting from 00:00 to 23:59. 6 | */ 7 | 8 | void jack_bauer(void) 9 | { 10 | int hour; 11 | int minute; 12 | 13 | for (hour = 0; hour < 24; hour++) 14 | { 15 | for (minute = 0; minute < 60; minute++) 16 | { 17 | _putchar('0' + (hour / 10)); 18 | _putchar('0' + (hour % 10)); 19 | _putchar(':'); 20 | _putchar('0' + (minute / 10)); 21 | _putchar('0' + (minute % 10)); 22 | _putchar('\n'); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/9-fizz_buzz.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - Entry point 5 | * 6 | * Return: Always 0 (Success) 7 | */ 8 | int main(void) 9 | { 10 | int i; 11 | 12 | for (i = 1; i <= 100; i++) 13 | { 14 | if (i % 3 == 0 && i % 5 == 0) 15 | { 16 | printf("FizzBuzz "); 17 | } 18 | else if (i % 3 == 0) 19 | { 20 | printf("Fizz "); 21 | } 22 | else if (i % 5 == 0) 23 | { 24 | printf("Buzz "); 25 | } 26 | else 27 | { 28 | printf("%d ", i); 29 | } 30 | } 31 | 32 | printf("\n"); 33 | 34 | return (0); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/9-times_table.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * times_table - prints time table for no. 9 5 | */ 6 | 7 | void times_table(void) 8 | { 9 | int num; 10 | int multiply; 11 | int product; 12 | 13 | for (num = 0; num <= 9; num++) 14 | { 15 | _putchar('0'); 16 | 17 | 18 | for (multiply = 1; multiply <= 9; multiply++) 19 | { 20 | _putchar(','); 21 | _putchar(' '); 22 | 23 | product = num * multiply; 24 | 25 | if (product <= 9) 26 | _putchar(' '); 27 | else 28 | _putchar('0' + (product / 10)); 29 | _putchar('0' + (product % 10)); 30 | } 31 | 32 | _putchar('\n'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/README.md: -------------------------------------------------------------------------------- 1 | functions and nested loops practice on C programming language 2 | -------------------------------------------------------------------------------- /0x02-functions_nested_loops/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | #include 4 | 5 | int _putchar(char b); 6 | void print_alphabet(void); 7 | void print_alphabet_x10(void); 8 | int _islower(int b); 9 | int _isalpha(int b); 10 | int print_sign(int k); 11 | int _abs(int); 12 | int print_last_digit(int); 13 | void jack_bauer(void); 14 | void times_table(void); 15 | int add(int, int); 16 | void print_to_98(int k); 17 | void print_times_table(int k); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /0x03-debugging/0-main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * main - tests function that prints if integer is positive or negative 5 | * Return: 0 6 | */ 7 | 8 | int main(void) 9 | { 10 | int i; 11 | 12 | i = 0; 13 | positive_or_negative(i); 14 | 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x03-debugging/1-main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /** 4 | * main - causes an infinite loop 5 | * Return: 0 6 | */ 7 | 8 | int main(void) 9 | { 10 | int i; 11 | 12 | printf("infinite loop incoming 13 | :(\n"); 14 | 15 | i = 0; 16 | 17 | /* while (i < 10)*/ 18 | /* {*/ 19 | /* putchar(i);*/ 20 | /* }*/ 21 | 22 | printf("infinite loop avoided! 23 | \\o/\n"); 24 | 25 | return (0); 26 | } 27 | -------------------------------------------------------------------------------- /0x03-debugging/README.md: -------------------------------------------------------------------------------- 1 | introduction to debugging 2 | -------------------------------------------------------------------------------- /0x03-debugging/git: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git add . 3 | read -p 'Commit message: ' message 4 | git commit -m $message 5 | git push 6 | -------------------------------------------------------------------------------- /0x03-debugging/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | #include 5 | 6 | void positive_or_negative(int i); 7 | int largest_number(int a, int b, int c); 8 | int convert_day(int month, int day); 9 | int print_remaining_days(int month, int day, int year); 10 | 11 | #endif /*MAIN_H*/ 12 | -------------------------------------------------------------------------------- /0x03-debugging/new: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read -p "File name: " name 3 | chmod u+x $name 4 | vi $name 5 | git add $name 6 | read -p 'Commit message: ' message 7 | git commit -m $message 8 | git push 9 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/.5-more_numbers.c.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melsayedahmed/alx-low_level_programming/3e193bce62d2182f68025e12ad1fe037eb3a6e0d/0x04-more_functions_nested_loops/.5-more_numbers.c.swp -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/0-isupper.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _isupper - uppercase letters 5 | * @c: character to check 6 | * 7 | * Return: 0 or 1 8 | */ 9 | 10 | int _isupper(int c) 11 | { 12 | if (c >= 'A' && c <= 'Z') 13 | return (1); 14 | else 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/1-isdigit.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _isdigit - write a function that checks for a digit 5 | * (0 through 9) 6 | * @c: char to check 7 | * Return: 1 or 0 8 | */ 9 | 10 | int _isdigit(int c) 11 | { 12 | if (c >= '0' && c <= '9') 13 | return (1); 14 | else 15 | return (0); 16 | } 17 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/2-mul.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "main.h" 3 | 4 | /** 5 | * mul - multiplies two integers 6 | * @a: first number 7 | * @b: second number 8 | * Return: multiplication of a and b 9 | */ 10 | 11 | int mul(int a, int b) 12 | { 13 | return (a * b); 14 | } 15 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/3-print_numbers.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_numbers - print 0123456789 5 | * 6 | * Return: void 7 | */ 8 | 9 | void print_numbers(void) 10 | { 11 | char c; 12 | 13 | for (c = '0'; c <= '9'; c++) 14 | { 15 | _putchar(c); 16 | } 17 | _putchar('\n'); 18 | } 19 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/4-print_most_numbers.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_most_numbers - prints numbers 0 to 9 5 | * 6 | * Return: Always 0. 7 | */ 8 | 9 | void print_most_numbers(void) 10 | { 11 | char c; 12 | 13 | for (c = '0'; c <= 9; c++) 14 | { 15 | if (!(c == '2' || c == '4')) 16 | _putchar(c); 17 | } 18 | _putchar('\n'); 19 | } 20 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/README.md: -------------------------------------------------------------------------------- 1 | more practice of C functions, creation of header files , nested loops 2 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/git: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git add . 3 | read -p 'Commit message: ' message 4 | git commit -m $message 5 | git push 6 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | int _isupper(int c); 5 | int _isdigit(int c); 6 | int mul(int a, int b); 7 | void print_numbers(void); 8 | void print_most_numbers(void); 9 | void more_numbers(void); 10 | void print_line(int n); 11 | void print_diagonal(int n); 12 | void print_square(int size); 13 | void print_triangle(int size); 14 | int _putchar(char c); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /0x04-more_functions_nested_loops/new: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read -p "File name: " name 3 | chmod u+x $name 4 | vi $name 5 | git add $name 6 | read -p 'Commit message: ' message 7 | git commit -m $message 8 | git push 9 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/0-reset_to_98.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * reset_to_98 - a function that takes a pointer to an int as parameter 4 | * and updates the value it points to to 98 5 | * @n: input 6 | * Return: n 7 | */ 8 | void reset_to_98(int *n) 9 | { 10 | *n = 98; 11 | } 12 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/1-swap.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * swap_int - swaps the values of two integers 4 | * @a: integer to swap 5 | * @b: integer to swap 6 | */ 7 | void swap_int(int *a, int *b) 8 | { 9 | int m; 10 | 11 | m = *a; 12 | *a = *b; 13 | *b = m; 14 | } 15 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/100-atoi.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _atoi - converts a string to an integer 5 | * @s: string to be converted 6 | * 7 | * Return: the int converted from the string 8 | */ 9 | int _atoi(char *s) 10 | { 11 | int i, d, n, len, f, digit; 12 | 13 | i = 0; 14 | d = 0; 15 | n = 0; 16 | len = 0; 17 | f = 0; 18 | digit = 0; 19 | 20 | while (s[len] != '\0') 21 | len++; 22 | 23 | while (i < len && f == 0) 24 | { 25 | if (s[i] == '-') 26 | ++d; 27 | 28 | if (s[i] >= '0' && s[i] <= '9') 29 | { 30 | digit = s[i] - '0'; 31 | if (d % 2) 32 | digit = -digit; 33 | n = n * 10 + digit; 34 | f = 1; 35 | if (s[i + 1] < '0' || s[i + 1] > '9') 36 | break; 37 | f = 0; 38 | } 39 | i++; 40 | } 41 | 42 | if (f == 0) 43 | return (0); 44 | 45 | return (n); 46 | } 47 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/101-keygen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /** 6 | * main - program that generates random valid 7 | * passwords for the program 101-crackme 8 | * 9 | * Return: Always 0 (Success) 10 | */ 11 | int main(void) 12 | { 13 | int pass[100]; 14 | int i, sum, n; 15 | 16 | sum = 0; 17 | 18 | srand(time(NULL)); 19 | 20 | for (i = 0; i < 100; i++) 21 | { 22 | pass[i] = rand() % 78; 23 | sum += (pass[i] + '0'); 24 | putchar(pass[i] + '0'); 25 | if ((2772 - sum) - '0' < 78) 26 | { 27 | n = 2772 - sum - '0'; 28 | sum += n; 29 | putchar(n + '0'); 30 | break; 31 | } 32 | } 33 | 34 | return (0); 35 | } 36 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/2-strlen.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _strlen - returns the length of a string 4 | * @s: string 5 | * Return: length 6 | */ 7 | int _strlen(char *s) 8 | { 9 | int longi = 0; 10 | 11 | while (*s != '\0') 12 | { 13 | longi++; 14 | s++; 15 | } 16 | 17 | return (longi); 18 | } 19 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/3-puts.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _puts - prints a string, followed by a new line, to stdout 4 | * @str: string to print 5 | */ 6 | void _puts(char *str) 7 | { 8 | while (*str != '\0') 9 | { 10 | _putchar(*str++); 11 | } 12 | _putchar('\n'); 13 | } 14 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/4-print_rev.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * print_rev - imprime en reversa 4 | * @s: string 5 | * return: 0 6 | */ 7 | void print_rev(char *s) 8 | { 9 | int longi = 0; 10 | int o; 11 | 12 | while (*s != '\0') 13 | { 14 | longi++; 15 | s++; 16 | } 17 | s--; 18 | for (o = longi; o > 0; o--) 19 | { 20 | _putchar(*s); 21 | s--; 22 | } 23 | 24 | _putchar('\n'); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/5-rev_string.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * rev_string - Reverses a string 5 | * @s: Input string 6 | * Return: String in reverse 7 | */ 8 | 9 | void rev_string(char *s) 10 | { 11 | char rev = s[0]; 12 | int counter = 0; 13 | int i; 14 | 15 | while (s[counter] != '\0') 16 | counter++; 17 | for (i = 0; i < counter; i++) 18 | { 19 | counter--; 20 | rev = s[i]; 21 | s[i] = s[counter]; 22 | s[counter] = rev; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/6-puts2.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * puts2 - function should print only one character out of two 4 | * starting with the first one 5 | * @str: input 6 | * Return: print 7 | */ 8 | void puts2(char *str) 9 | { 10 | int longi = 0; 11 | int t = 0; 12 | char *y = str; 13 | int o; 14 | 15 | while (*y != '\0') 16 | { 17 | y++; 18 | longi++; 19 | } 20 | t = longi - 1; 21 | for (o = 0 ; o <= t ; o++) 22 | { 23 | if (o % 2 == 0) 24 | { 25 | _putchar(str[o]); 26 | } 27 | } 28 | _putchar('\n'); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/7-puts_half.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * puts_half - a function that prints half of a string 4 | * if odd len, n = (length_of_the_string - 1) / 2 5 | * @str: input 6 | * Return: half of input 7 | */ 8 | void puts_half(char *str) 9 | { 10 | int a, n, longi; 11 | 12 | longi = 0; 13 | 14 | for (a = 0; str[a] != '\0'; a++) 15 | longi++; 16 | 17 | n = (longi / 2); 18 | 19 | if ((longi % 2) == 1) 20 | n = ((longi + 1) / 2); 21 | 22 | for (a = n; str[a] != '\0'; a++) 23 | _putchar(str[a]); 24 | _putchar('\n'); 25 | } 26 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/8-print_array.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_array - a function that prints n elements of an array 5 | * @a: array name 6 | * @n: is the number of elements OF the array to be printed 7 | * Return: a and n inputs 8 | */ 9 | void print_array(int *a, int n) 10 | { 11 | int i; 12 | 13 | for (i = 0; i < (n - 1); i++) 14 | { 15 | printf("%d, ", a[i]); 16 | } 17 | if (i == (n - 1)) 18 | { 19 | printf("%d", a[n - 1]); 20 | } 21 | printf("\n"); 22 | } 23 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/9-strcpy.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * char *_strcpy - a function that copies the string pointed to by src 5 | * @dest: copy to 6 | * @src: copy from 7 | * Return: string 8 | */ 9 | char *_strcpy(char *dest, char *src) 10 | { 11 | int l = 0; 12 | int x = 0; 13 | 14 | while (*(src + l) != '\0') 15 | { 16 | l++; 17 | } 18 | for ( ; x < l ; x++) 19 | { 20 | dest[x] = src[x]; 21 | } 22 | dest[l] = '\0'; 23 | return (dest); 24 | } 25 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/README.md: -------------------------------------------------------------------------------- 1 | practicals on C pointers, arrays and strings 2 | -------------------------------------------------------------------------------- /0x05-pointers_arrays_strings/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | #include 5 | #include 6 | 7 | int _putchar(char c); 8 | void reset_to_98(int *n); 9 | void swap_int(int *a, int *b); 10 | int _strlen(char *s); 11 | void _puts(char *str); 12 | void print_rev(char *s); 13 | void rev_string(char *s); 14 | void puts2(char *str); 15 | void puts_half(char *str); 16 | void print_array(int *a, int n); 17 | char *_strcpy(char *dest, char *src); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/0-strcat.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _strcat - concatenates two strings 4 | * @dest: input value 5 | * @src: input value 6 | * 7 | * Return: void 8 | */ 9 | char *_strcat(char *dest, char *src) 10 | { 11 | int i; 12 | int j; 13 | 14 | i = 0; 15 | while (dest[i] != '\0') 16 | { 17 | i++; 18 | } 19 | j = 0; 20 | while (src[j] != '\0') 21 | { 22 | dest[i] = src[j]; 23 | i++; 24 | j++; 25 | } 26 | 27 | dest[i] = '\0'; 28 | return (dest); 29 | } 30 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/1-strncat.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _strncat - concatenate two strings 4 | * using at most n bytes from src 5 | * @dest: input value 6 | * @src: input value 7 | * @n: input value 8 | * 9 | * Return: dest 10 | */ 11 | char *_strncat(char *dest, char *src, int n) 12 | { 13 | int i; 14 | int j; 15 | 16 | i = 0; 17 | while (dest[i] != '\0') 18 | { 19 | i++; 20 | } 21 | j = 0; 22 | while (j < n && src[j] != '\0') 23 | { 24 | dest[i] = src[j]; 25 | i++; 26 | j++; 27 | } 28 | dest[i] = '\0'; 29 | return (dest); 30 | } 31 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/100-rot13.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * rot13 - encoder rot13 6 | * @s: pointer to string params 7 | * 8 | * Return: *s 9 | */ 10 | 11 | char *rot13(char *s) 12 | { 13 | int i; 14 | int j; 15 | char data1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 16 | char datarot[] = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"; 17 | 18 | for (i = 0; s[i] != '\0'; i++) 19 | { 20 | for (j = 0; j < 52; j++) 21 | { 22 | if (s[i] == data1[j]) 23 | { 24 | s[i] = datarot[j]; 25 | break; 26 | } 27 | } 28 | } 29 | return (s); 30 | } 31 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/101-print_number.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_number - print numbers chars 5 | * @n: integer params 6 | * Return: 0 7 | */ 8 | 9 | void print_number(int n) 10 | { 11 | unsigned int n1; 12 | 13 | n1 = n; 14 | 15 | if (n < 0) 16 | { 17 | _putchar('-'); 18 | n1 = -n; 19 | } 20 | 21 | if (n1 / 10 != 0) 22 | { 23 | print_number(n1 / 10); 24 | } 25 | _putchar((n1 % 10) + '0'); 26 | } 27 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/102-magic.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | int n; 6 | int a[5]; 7 | int *p; 8 | 9 | a[2] = 1024; 10 | p = &n; 11 | /* 12 | * write your line of code here... 13 | * Remember: 14 | * - you are not allowed to use a 15 | * - you are not allowed to modify p 16 | * - only one statement 17 | * - you are not allowed to code anything else than this line of code 18 | */ 19 | *(p + 5) = 98; 20 | /* ...so that this prints 98\n */ 21 | printf("a[2] = %d\n", a[2]); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/103-infinite_add.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * rev_string - reverse array 5 | * @n: integer params 6 | * Return: 0 7 | */ 8 | 9 | void rev_string(char *n) 10 | { 11 | int i = 0; 12 | int j = 0; 13 | char temp; 14 | 15 | while (*(n + i) != '\0') 16 | { 17 | i++; 18 | } 19 | i--; 20 | 21 | for (j = 0; j < i; j++, i--) 22 | { 23 | temp = *(n + j); 24 | *(n + j) = *(n + i); 25 | *(n + i) = temp; 26 | } 27 | } 28 | 29 | /** 30 | * infinite_add - add 2 numbers together 31 | * @n1: text representation of 1st number to add 32 | * @n2: text representation of 2nd number to add 33 | * @r: pointer to buffer 34 | * @size_r: buffer size 35 | * Return: pointer to calling function 36 | */ 37 | 38 | char *infinite_add(char *n1, char *n2, char *r, int size_r) 39 | { 40 | int overflow = 0, i = 0, j = 0, digits = 0; 41 | int val1 = 0, val2 = 0, temp_tot = 0; 42 | 43 | while (*(n1 + i) != '\0') 44 | i++; 45 | while (*(n2 + j) != '\0') 46 | j++; 47 | i--; 48 | j--; 49 | if (j >= size_r || i >= size_r) 50 | return (0); 51 | while (j >= 0 || i >= 0 || overflow == 1) 52 | { 53 | if (i < 0) 54 | val1 = 0; 55 | else 56 | val1 = *(n1 + i) - '0'; 57 | if (j < 0) 58 | val2 = 0; 59 | else 60 | val2 = *(n2 + j) - '0'; 61 | temp_tot = val1 + val2 + overflow; 62 | if (temp_tot >= 10) 63 | overflow = 1; 64 | else 65 | overflow = 0; 66 | if (digits >= (size_r - 1)) 67 | return (0); 68 | *(r + digits) = (temp_tot % 10) + '0'; 69 | digits++; 70 | j--; 71 | i--; 72 | } 73 | if (digits == size_r) 74 | return (0); 75 | *(r + digits) = '\0'; 76 | rev_string(r); 77 | return (r); 78 | } 79 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/104-print_buffer.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | /** 5 | * print_buffer - prints buffer 6 | * @b: buffer 7 | * @size: size 8 | * Return: void 9 | */ 10 | 11 | void print_buffer(char *b, int size) 12 | { 13 | int o, j, i; 14 | 15 | o = 0; 16 | 17 | if (size <= 0) 18 | { 19 | printf("\n"); 20 | return; 21 | } 22 | while (o < size) 23 | { 24 | j = size - o < 10 ? size - o : 10; 25 | printf("%08x: ", o); 26 | for (i = 0; i < 10; i++) 27 | { 28 | if (i < j) 29 | printf("%02x", *(b + o + i)); 30 | else 31 | printf(" "); 32 | if (i % 2) 33 | { 34 | printf(" "); 35 | } 36 | } 37 | for (i = 0; i < j; i++) 38 | { 39 | int c = *(b + o + i); 40 | 41 | if (c < 32 || c > 132) 42 | { 43 | c = '.'; 44 | } 45 | printf("%c", c); 46 | } 47 | printf("\n"); 48 | o += 10; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/2-strncpy.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _strncpy - copy a string 4 | * @dest: input value 5 | * @src: input value 6 | * @n: input value 7 | * 8 | * Return: dest 9 | */ 10 | char *_strncpy(char *dest, char *src, int n) 11 | { 12 | int j; 13 | 14 | j = 0; 15 | while (j < n && src[j] != '\0') 16 | { 17 | dest[j] = src[j]; 18 | j++; 19 | } 20 | while (j < n) 21 | { 22 | dest[j] = '\0'; 23 | j++; 24 | } 25 | 26 | return (dest); 27 | } 28 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/3-strcmp.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _strcmp - compare string values 4 | * @s1: input value 5 | * @s2: input value 6 | * 7 | * Return: s1[i] - s2[i] 8 | */ 9 | int _strcmp(char *s1, char *s2) 10 | { 11 | int i; 12 | 13 | i = 0; 14 | while (s1[i] != '\0' && s2[i] != '\0') 15 | { 16 | if (s1[i] != s2[i]) 17 | { 18 | return (s1[i] - s2[i]); 19 | } 20 | i++; 21 | } 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/4-rev_array.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * reverse_array - reverse array of integers 4 | * @a: array 5 | * @n: number of elements of array 6 | * 7 | * Return: void 8 | */ 9 | void reverse_array(int *a, int n) 10 | { 11 | int i; 12 | int t; 13 | 14 | for (i = 0; i < n--; i++) 15 | { 16 | t = a[i]; 17 | a[i] = a[n]; 18 | a[n] = t; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/5-string_toupper.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * string_toupper - change all lowercase to uppercase 4 | * @n: pointer 5 | * 6 | * Return: n 7 | */ 8 | char *string_toupper(char *n) 9 | { 10 | int i; 11 | 12 | i = 0; 13 | while (n[i] != '\0') 14 | { 15 | if (n[i] >= 'a' && n[i] <= 'z') 16 | n[i] = n[i] - 32; 17 | i++; 18 | } 19 | return (n); 20 | } 21 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/6-cap_string.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * cap_string - Capitalizes all words of a string. 5 | * @str: The string to be capitalized. 6 | * 7 | * Return: A pointer to the changed string. 8 | */ 9 | char *cap_string(char *str) 10 | { 11 | int index = 0; 12 | 13 | while (str[index]) 14 | { 15 | while (!(str[index] >= 'a' && str[index] <= 'z')) 16 | index++; 17 | 18 | if (str[index - 1] == ' ' || 19 | str[index - 1] == '\t' || 20 | str[index - 1] == '\n' || 21 | str[index - 1] == ',' || 22 | str[index - 1] == ';' || 23 | str[index - 1] == '.' || 24 | str[index - 1] == '!' || 25 | str[index - 1] == '?' || 26 | str[index - 1] == '"' || 27 | str[index - 1] == '(' || 28 | str[index - 1] == ')' || 29 | str[index - 1] == '{' || 30 | str[index - 1] == '}' || 31 | index == 0) 32 | str[index] -= 32; 33 | 34 | index++; 35 | } 36 | 37 | return (str); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/7-leet.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * leet - encode into 1337speak 4 | * @n: input value 5 | * Return: n value 6 | */ 7 | char *leet(char *n) 8 | { 9 | int i, j; 10 | char s1[] = "aAeEoOtTlL"; 11 | char s2[] = "4433007711"; 12 | 13 | for (i = 0; n[i] != '\0'; i++) 14 | { 15 | for (j = 0; j < 10; j++) 16 | { 17 | if (n[i] == s1[j]) 18 | { 19 | n[i] = s2[j]; 20 | } 21 | } 22 | } 23 | return (n); 24 | } 25 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/README.md: -------------------------------------------------------------------------------- 1 | More practice of pointers arrays strings manipulations in C programming language 2 | -------------------------------------------------------------------------------- /0x06-pointers_arrays_strings/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | int _putchar(char c); 5 | char *_strcat(char *dest, char *src); 6 | char *_strncat(char *dest, char *src, int n); 7 | char *_strncpy(char *dest, char *src, int n); 8 | int _strcmp(char *s1, char *s2); 9 | void reverse_array(int *a, int n); 10 | char *string_toupper(char *a); 11 | char *cap_string(char *a); 12 | char *leet(char *a); 13 | char *rot13(char *a); 14 | void print_number(int n); 15 | char *infinite_add(char *n1, char *n2, char *r, int size_r); 16 | void print_buffer(char *b, int size); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/0-memset.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _memset - function fill the first @n bytes of the 5 | * memory area pointed 6 | * to by @s with the constant byte @b 7 | * 8 | * @n: bytes of the memory area pointed to by @s 9 | * 10 | * @s: with the constant byte @b 11 | * 12 | * @b: memory area pointer 13 | * 14 | * Return: a pointer to the memory area @s 15 | */ 16 | char *_memset(char *s, char b, unsigned int n) 17 | { 18 | unsigned int i = 0; 19 | 20 | while (i < n) 21 | { 22 | s[i] = b; 23 | i++; 24 | } 25 | 26 | return (s); 27 | } 28 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/1-memcpy.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _memcpy - function copies @n bytes from memory area @src 5 | * to memory area @dest 6 | * 7 | * @n: function copies 8 | * 9 | * @src: bytes from memory area 10 | * 11 | * @dest: to memory area 12 | * 13 | * Return: a pointer to @dest 14 | */ 15 | char *_memcpy(char *dest, char *src, unsigned int n) 16 | { 17 | unsigned int i = 0; 18 | 19 | while (i < n) 20 | { 21 | dest[i] = src[i]; 22 | i++; 23 | } 24 | 25 | return (dest); 26 | } 27 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/100-set_string.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * set_string - sets the value of a pointer to a char 4 | * @s: pointer to change 5 | * @to: string to change pointer to 6 | * 7 | * Return: void 8 | */ 9 | void set_string(char **s, char *to) 10 | { 11 | *s = to; 12 | } 13 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/101-crackme_password: -------------------------------------------------------------------------------- 1 | abc123 2 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/2-strchr.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _strchr - locates a character in a string 5 | * 6 | * @c: occurrence of the character 7 | * 8 | * @s: in the string 9 | * 10 | * Return: a pointer to the first occurrence of the character 11 | */ 12 | 13 | char *_strchr(char *s, char c) 14 | { 15 | while (*s) 16 | { 17 | if (*s != c) 18 | s++; 19 | else 20 | return (s); 21 | } 22 | if (c == '\0') 23 | return (s); 24 | 25 | return (NULL); 26 | } 27 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/3-strspn.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _strspn - a function that gets the length of a prefix substring 5 | * 6 | * @s: the initial segment of 7 | * 8 | * @accept: which consist only of bytes from 9 | * 10 | * Return: the number of bytes 11 | */ 12 | 13 | unsigned int _strspn(char *s, char *accept) 14 | { 15 | int z = 0, x, y; 16 | 17 | for (x = 0; s[x] != '\0'; x++) 18 | { 19 | if (s[x] != 32) 20 | { 21 | for (y = 0; accept[y] != '\0'; y++) 22 | { 23 | if (s[x] == accept[y]) 24 | z++; 25 | } 26 | } 27 | else 28 | return (z); 29 | } 30 | return (z); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/4-strpbrk.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _strpbrk - function that searches a string for any of a set of bytes 5 | * 6 | * @s:first occurrence in the string 7 | * 8 | * @accept: matches one of the bytes, or @NULL if no such byte 9 | * 10 | * Return: a pointer to the byte 11 | */ 12 | char *_strpbrk(char *s, char *accept) 13 | { 14 | int i; 15 | while (*s) 16 | { 17 | for (i = 0; accept[i]; i++) 18 | { 19 | if (*s == accept[i]) 20 | return (s); 21 | } 22 | s++; 23 | } 24 | return (NULL); 25 | } 26 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/5-strstr.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * _strstr - locates a substring 5 | * 6 | * @haystack: the longer string to search 7 | * @needle: the first occurrence of the substring 8 | * 9 | * Return: a pointer beg of substring or @Null if it not foound. 10 | */ 11 | char *_strstr(char *haystack, char *needle) 12 | { 13 | unsigned int i = 0, j = 0; 14 | 15 | while (haystack[i]) 16 | { 17 | while (needle[j] && (haystack[i] == needle[0])) 18 | { 19 | if (haystack[i + j] == needle[j]) 20 | j++; 21 | else 22 | break; 23 | } 24 | if (needle[j]) 25 | { 26 | i++; 27 | j = 0; 28 | } 29 | else 30 | return (haystack + i); 31 | } 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/7-print_chessboard.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * print_chessboard - prints the chessboard 5 | * @a: pointer to pieces to print 6 | * 7 | * Return: void 8 | */ 9 | void print_chessboard(char (*a)[8]) 10 | { 11 | int i, j; 12 | 13 | for (i = 0; i < 8; i++) 14 | { 15 | for (j = 0; j < 8; j++) 16 | { 17 | _putchar(a[i][j]); 18 | } 19 | _putchar('\n'); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/8-print_diagsums.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * print_diagsums - prints the sums of the two diagonals of a square matrix 4 | * @a: pointer to start of matrix 5 | * @size: width of matrix column 6 | * 7 | * Return: void 8 | */ 9 | void print_diagsums(int *a, int size) 10 | { 11 | int i, j, p, l = 0, r = 0; 12 | 13 | for (i = 0; i < size; i++) 14 | { 15 | p = (i * size) + i; 16 | l += *(a + p); 17 | } 18 | for (j = 0; j < size; j++) 19 | { 20 | p = (j * size) + (size - 1 - j); 21 | r += *(a + p); 22 | } 23 | printf("%i, %i\n", l, r); 24 | } 25 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/README.md: -------------------------------------------------------------------------------- 1 | further study and practice on C pointers ,multidimentional arrays, 2D arrays, strings and data manipulation with pointers 2 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/git: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git add . 3 | read -p 'Commit message: ' message 4 | git commit -m $message 5 | git push 6 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | 4 | #include 5 | #include 6 | 7 | char *_memset(char *s, char b, unsigned int n); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /0x07-pointers_arrays_strings/new: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | read -p "File name: " name 3 | chmod u+x $name 4 | vi $name 5 | git add $name 6 | read -p 'Commit message: ' message 7 | git commit -m $message 8 | git push 9 | -------------------------------------------------------------------------------- /0x08-recursion/0-puts_recursion.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _puts_recursion - print a string 4 | * @s:string 5 | * Return:void 6 | */ 7 | void _puts_recursion(char *s) 8 | { 9 | if (*s) 10 | { 11 | _putchar(*s); 12 | _puts_recursion(s + 1); 13 | } 14 | else 15 | { 16 | _putchar('\n'); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /0x08-recursion/1-print_rev_recursion.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _print_rev_recursion - print a string in reverse 4 | * @s: string 5 | * Return 0; 6 | */ 7 | 8 | void _print_rev_recursion(char *s) 9 | { 10 | if (*s) 11 | { 12 | _print_rev_recursion(s + 1); 13 | _putchar(*s); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /0x08-recursion/100-is_palindrome.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _strlen_recursion - Prints the length of a string. 4 | * @s: the string to be printed 5 | * Return: the length of string 6 | */ 7 | int _strlen_recursion(char *s) 8 | { 9 | if (s[0] != '\0') 10 | return (1 + _strlen_recursion(s + 1)); 11 | return (0); 12 | } 13 | /** 14 | * pal_checker - check if s is palindrome. 15 | * @s: string base address. 16 | * @i: left index. 17 | * @j: rigth index. 18 | * Return: 1 if s is palindrome, 0 otherwise. 19 | */ 20 | int pal_checker(char *s, int i, int j) 21 | { 22 | if (s[i] == s[j]) 23 | if (i > j / 2) 24 | return (1); 25 | else 26 | return (pal_checker(s, i + 1, j - 1)); 27 | else 28 | return (0); 29 | } 30 | /** 31 | * is_palindrome - check if s is palindrome 32 | * @s: base address for string. 33 | * 34 | * Return: 1 if n is prime, 0 otherwise. 35 | */ 36 | int is_palindrome(char *s) 37 | { 38 | return (pal_checker(s, 0, _strlen_recursion(s) - 1)); 39 | } 40 | -------------------------------------------------------------------------------- /0x08-recursion/101-wildcmp.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | /** 4 | * str_checker - check if two strings are identical. 5 | * @s1: string_1 base address. 6 | * @s2: string_2 base address. 7 | * @i: left index. 8 | * @j: special index. (joker) 9 | * Return: 1 if s is palindrome, 0 otherwise. 10 | */ 11 | int str_checker(char *s1, char *s2, int i, int j) 12 | { 13 | if (s1[i] == '\0' && s2[j] == '\0') 14 | return (1); 15 | if (s1[i] == s2[j]) 16 | return (str_checker(s1, s2, i + 1, j + 1)); 17 | if (s1[i] == '\0' && s2[j] == '*') 18 | return (str_checker(s1, s2, i, j + 1)); 19 | if (s2[j] == '*') 20 | return (str_checker(s1, s2, i + 1, j) || str_checker(s1, s2, i, j + 1)); 21 | return (0); 22 | } 23 | /** 24 | * wildcmp - check if strings could be considered identical 25 | * @s1: base address for string. 26 | * @s2: base address for string. 27 | * 28 | * Return: 1 if are considered identical. 29 | */ 30 | int wildcmp(char *s1, char *s2) 31 | { 32 | return (str_checker(s1, s2, 0, 0)); 33 | } 34 | -------------------------------------------------------------------------------- /0x08-recursion/2-strlen_recursion.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * _strlen_recursion - length of string 4 | * @s:string 5 | * Return:int 6 | */ 7 | int _strlen_recursion(char *s) 8 | { 9 | int i = 0; 10 | 11 | if (*s) 12 | { 13 | i++; 14 | i += _strlen_recursion(s + 1); 15 | 16 | } 17 | return (i); 18 | } 19 | -------------------------------------------------------------------------------- /0x08-recursion/3-factorial.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | /** 3 | * factorial - factorial of int 4 | * @n:int 5 | * Return:int 6 | */ 7 | int factorial(int n) 8 | { 9 | int x; 10 | 11 | if (n == 0) 12 | { 13 | return (1); 14 | } 15 | else if (n < 0) 16 | { 17 | return (-1); 18 | } 19 | else 20 | { 21 | x = n * factorial(n - 1); 22 | } 23 | return (x); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /0x08-recursion/4-pow_recursion.c: -------------------------------------------------------------------------------- 1 | 2 | #include "main.h" 3 | /** 4 | * _pow_recursion - power 5 | * @x:int 6 | * @y:int 7 | * Return:int 8 | */ 9 | 10 | int _pow_recursion(int x, int y) 11 | { 12 | if (y < 0) 13 | { 14 | return (-1); 15 | } 16 | else if (y != 0) 17 | return (x * _pow_recursion(x, y - 1)); 18 | 19 | else 20 | { 21 | return (1); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /0x08-recursion/5-sqrt_recursion.c: -------------------------------------------------------------------------------- 1 | 2 | #include "main.h" 3 | 4 | /** 5 | * check - checks for the square root 6 | * @a:int 7 | * @b:int 8 | * 9 | * Return: int 10 | */ 11 | int check(int a, int b) 12 | { 13 | if (a * a == b) 14 | return (a); 15 | if (a * a > b) 16 | return (-1); 17 | return (check(a + 1, b)); 18 | } 19 | 20 | /** 21 | * _sqrt_recursion - returns the natural square root of a number 22 | * @n: integer to find sqrt of 23 | * Return: natural square root or -1 24 | */ 25 | int _sqrt_recursion(int n) 26 | { 27 | if (n == 0) 28 | return (0); 29 | return (check(1, n)); 30 | } 31 | -------------------------------------------------------------------------------- /0x08-recursion/6-is_prime_number.c: -------------------------------------------------------------------------------- 1 | 2 | #include "main.h" 3 | 4 | /** 5 | * check - checks to see if number is prime 6 | * @a:int 7 | * @b:int 8 | * Return:int 9 | */ 10 | int check(int a, int b) 11 | { 12 | if (b < 2 || b % a == 0) 13 | return (0); 14 | else if (a > b / 2) 15 | return (1); 16 | else 17 | return (check(a + 1, b)); 18 | } 19 | 20 | /** 21 | * is_prime_number - states if number is prime 22 | * @n:int 23 | * Return:int 24 | */ 25 | int is_prime_number(int n) 26 | { 27 | if (n == 2) 28 | return (1); 29 | return (check(2, n)); 30 | } 31 | -------------------------------------------------------------------------------- /0x08-recursion/README.md: -------------------------------------------------------------------------------- 1 | Recursion on C programming language 2 | -------------------------------------------------------------------------------- /0x08-recursion/main.h: -------------------------------------------------------------------------------- 1 | int _putchar(char c); 2 | void _puts_recursion(char *s); 3 | void _print_rev_recursion(char *s); 4 | int _strlen_recursion(char *s); 5 | int factorial(int n); 6 | int _pow_recursion(int x, int y); 7 | int _sqrt_recursion(int n); 8 | int is_prime_number(int n); 9 | int is_palindrome(char *s); 10 | int wildcmp(char *s1, char *s2); 11 | -------------------------------------------------------------------------------- /0x09-static_libraries/README.md: -------------------------------------------------------------------------------- 1 | static libraries 2 | -------------------------------------------------------------------------------- /0x09-static_libraries/create_static_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcc -c *.c 3 | ar rc liball.a *.o 4 | ranlib liball.a 5 | -------------------------------------------------------------------------------- /0x09-static_libraries/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | #include 4 | 5 | int _putchar(char c); 6 | int _islower(int c); 7 | int _isalpha(int c); 8 | int _abs(int n); 9 | int _isupper(int c); 10 | int _isdigit(int c); 11 | int _strlen(char *s); 12 | void _puts(char *s); 13 | char *_strcpy(char *dest, char *src); 14 | int _atoi(char *s); 15 | char *_strcat(char *dest, char *src); 16 | char *_strncat(char *dest, char *src, int n); 17 | char *_strncpy(char *dest, char *src, int n); 18 | int _strcmp(char *s1, char *s2); 19 | char *_memset(char *s, char b, unsigned int n); 20 | char *_memcpy(char *dest, char *src, unsigned int n); 21 | char *_strchr(char *s, char c); 22 | unsigned int _strspn(char *s, char *accept); 23 | char *_strpbrk(char *s, char *accept); 24 | char *_strstr(char *haystack, char *needle); 25 | #endif 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A new project to learn and practice c programming language 2 | --------------------------------------------------------------------------------