File tree Expand file tree Collapse file tree 19 files changed +448
-0
lines changed Expand file tree Collapse file tree 19 files changed +448
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+
3
+ /**
4
+ * _isupper - function
5
+ * @c: first operand
6
+ *
7
+ * Description: checking for uppercase letters.
8
+ * Return: 1 if uppercase, 0 otherwise
9
+ */
10
+
11
+ int _isupper (int c )
12
+ {
13
+ if (c >= 65 && c <= 90 )
14
+ {
15
+ return (1 );
16
+ }
17
+ else
18
+ {
19
+ return (0 );
20
+ }
21
+ return (c );
22
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _memset - function
5
+ * @s: A pointer to the memory area to be filled.
6
+ * @b: The character to fill the memory area with.
7
+ * @n: The number of bytes to be filled.
8
+ *
9
+ * Description: Function to fill memory with a constant byte
10
+ * Return: pointer to filled memory of s
11
+ */
12
+ char * _memset (char * s , char b , unsigned int n )
13
+ {
14
+ unsigned int i ;
15
+
16
+ for (i = 0 ; i < n ; i ++ )
17
+ s [i ] = b ;
18
+
19
+ return (s );
20
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _strcat - function
5
+ * @dest: add to string
6
+ *
7
+ * @src: add from string
8
+ * function to concat two strings
9
+ *
10
+ * Return: dest
11
+ *
12
+ **/
13
+
14
+ char * _strcat (char * dest , char * src )
15
+ {
16
+
17
+ int len ;
18
+
19
+ int len2 ;
20
+
21
+ for (len = 0 ; dest [len ]; len ++ )
22
+ ;
23
+
24
+ for (len2 = 0 ; src [len2 ]; len2 ++ )
25
+ {
26
+ dest [len ] = src [len2 ];
27
+
28
+ len ++ ;
29
+
30
+ }
31
+ return (dest );
32
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ /**
3
+ * _isdigit - function
4
+ * @c: first operand
5
+ *
6
+ * Description: checks for a digit (0 through 9)
7
+ * Return: 1 if c is a digit, 0 otherwise.
8
+ */
9
+ int _isdigit (int c )
10
+ {
11
+ if (c >= 48 && c <= 57 )
12
+ {
13
+ return (1 );
14
+ }
15
+ else
16
+ {
17
+ return (0 );
18
+ }
19
+ return (c );
20
+ }
21
+
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _memcpy -copies memory area from src to dest
5
+ * @dest: destination
6
+ * @src: source
7
+ * @n: max bytes to use
8
+ * Return: dest
9
+ */
10
+
11
+ char * _memcpy (char * dest , char * src , unsigned int n )
12
+ {
13
+ unsigned int i ;
14
+
15
+ for (i = 0 ; n > 0 ; i ++ , n -- )
16
+ {
17
+ dest [i ] = src [i ];
18
+ }
19
+
20
+ return (dest );
21
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ /**
3
+ * _strncat - concatenate two strings.
4
+ * @dest: Type char
5
+ * @src: Type char
6
+ * @n: Type int
7
+ *
8
+ * Return: dest
9
+ */
10
+ char * _strncat (char * dest , char * src , int n )
11
+ {
12
+ int a , b ;
13
+
14
+ for (a = 0 ; dest [a ] != '\0' ; a ++ )
15
+ {
16
+ }
17
+ for (b = 0 ; b < n && src [b ] != '\0' ; b ++ )
18
+ {
19
+ dest [a + b ] = src [b ];
20
+ }
21
+ return (dest );
22
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ /**
3
+ * _atoi - Convert string to integer.
4
+ * @s: Pointer to a character string.
5
+ *
6
+ * Return: void.
7
+ */
8
+
9
+ int _atoi (char * s )
10
+ {
11
+ int sign ;
12
+ unsigned int num ;
13
+ char * temp ;
14
+
15
+ temp = s ;
16
+ num = 0 ;
17
+ sign = 1 ;
18
+ while (* temp != '\0' && (* temp < '0' || * temp > '9' ))
19
+ {
20
+ if (* temp == '-' )
21
+ sign *= -1 ;
22
+ temp ++ ;
23
+ }
24
+ if (* temp != '\0' )
25
+ {
26
+ do {
27
+ num = num * 10 + (* temp - '0' );
28
+ temp ++ ;
29
+ } while (* temp >= '0' && * temp <= '0' );
30
+ }
31
+ return (num * sign );
32
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _strchr - Locates a character in a string
5
+ * @s: The string to be searched.
6
+ * @c: The character to be located.
7
+ *
8
+ * Return: If c is found - a pointer to the first occurence.
9
+ * If c is not found - NULL
10
+ */
11
+ char * _strchr (char * s , char c )
12
+ {
13
+ int index ;
14
+
15
+ for (index = 0 ; s [index ] >= '\0' ; index ++ )
16
+ {
17
+ if (s [index ] == c )
18
+ return (s + index );
19
+ }
20
+
21
+ return ('\0' );
22
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ /**
3
+ * _strlen - returns the length of a string.
4
+ *
5
+ * @s: Type char
6
+ * Return: a
7
+ */
8
+
9
+ int _strlen (char * s )
10
+ {
11
+ int a ;
12
+
13
+ for (a = 0 ; s [a ] != '\0' ; a ++ )
14
+ {
15
+
16
+ }
17
+ return (a );
18
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ /**
3
+ * _strncat - concatenate two strings.
4
+ * @dest: Type char
5
+ * @src: Type char
6
+ * @n: Type int
7
+ *
8
+ * Return: dest
9
+ */
10
+ char * _strncat (char * dest , char * src , int n )
11
+ {
12
+ int a , b ;
13
+
14
+ for (a = 0 ; dest [a ] != '\0' ; a ++ )
15
+ {
16
+ }
17
+ for (b = 0 ; b < n && src [b ] != '\0' ; b ++ )
18
+ {
19
+ dest [a + b ] = src [b ];
20
+ }
21
+ return (dest );
22
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _islower - function to check for lowercase char
5
+ * @c: first operand
6
+ *
7
+ * Description:check for lowercase letters
8
+ * Return: 1 if c is lowercase, 0 otherwise
9
+ */
10
+ int _islower (int c )
11
+ {
12
+ if (c >= 97 && c <= 122 )
13
+ {
14
+ return (1 );
15
+ }
16
+ else
17
+ {
18
+ return (0 );
19
+ }
20
+ return (c );
21
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _puts - prints a string.
5
+ * @str: Type char
6
+ */
7
+
8
+ void _puts (char * str )
9
+ {
10
+ int a ;
11
+
12
+ for (a = 0 ; str [a ] != '\0' ; a ++ )
13
+ {
14
+ _putchar (str [a ]);
15
+ }
16
+ _putchar ('\n' );
17
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ n
3
+ /**
4
+ * _strcmp - compare two strings
5
+ * @s1: Type char
6
+ * @s2: Type char
7
+ * Return: b
8
+ */
9
+ int _strcmp(char *s1, char *s2)
10
+ {
11
+ int a = 0;
12
+ int b = 0;
13
+
14
+ while (s1[a] != '\0' && s2[a] != '\0' && s1[a] == s2[a])
15
+ {
16
+ a++;
17
+ }
18
+ b = s1[a] - s2[a];
19
+ return (b);
20
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * _strspn - gets the length of a prefix substring
5
+ * @s: string to evaluate
6
+ * @accept: string containing the list of characters to match in s
7
+ *
8
+ * Return: the number of bytes in the initial segment
9
+ * of a which consist only of bytes from accept
10
+ */
11
+ unsigned int _strspn (char * s , char * accept )
12
+ {
13
+ int i , j , f , flag ;
14
+
15
+ f = 0 ;
16
+
17
+ for (i = 0 ; s [i ] != '\0' ; i ++ )
18
+ {
19
+ flag = 0 ;
20
+ for (j = 0 ; accept [j ] != '\0' ; j ++ )
21
+ {
22
+ if (s [i ] == accept [j ])
23
+ {
24
+ i ++ ;
25
+ flag = 1 ;
26
+ }
27
+ }
28
+ if (flag == 0 )
29
+ {
30
+ return (f );
31
+ }
32
+ }
33
+
34
+ return (0 );
35
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+ /**
3
+ * _isalpha - checks for alphabetic character
4
+ * @c: First operand
5
+ *
6
+ * Description: checks for lower and upper alpha chars
7
+ * Return:1 if c is a letter, lowercase or uppercase, 0 otherwise
8
+ */
9
+ int _isalpha (int c )
10
+ {
11
+ if (c >= 65 && c <= 90 )
12
+ {
13
+ return (1 );
14
+ }
15
+ else if (c >= 97 && c <= 122 )
16
+ {
17
+ return (1 );
18
+ }
19
+ else
20
+ {
21
+ return (0 );
22
+ }
23
+ return (c );
24
+ }
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include "main.h"
3
+
4
+ /**
5
+ * _strpbrk - search a string for any of a set of bytes
6
+ * @*s: input Char Type
7
+ * @*accept: input Char Type
8
+ *
9
+ * Return Always 0 (success)
10
+ */
11
+ char * _strpbrk (char * s , char * accept )
12
+ {
13
+ int i , n ;
14
+
15
+ for (i = 0 ; s [i ] != '\0' ; i ++ )
16
+ {
17
+ for (n = 0 ; accept [n ] != '\0' ; n ++ )
18
+ {
19
+ if (s [i ] == accept [n ])
20
+ return (s + i );
21
+ }
22
+ }
23
+ return (NULL );
24
+ }
You can’t perform that action at this time.
0 commit comments