-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.c
More file actions
82 lines (73 loc) · 1.25 KB
/
Copy pathutil.c
File metadata and controls
82 lines (73 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "main.h"
/**
* _strcpy - copies the string pointed to by src, to the buffer
* @dest: destination
* @src: source
* Return: the pointer to dest
**/
char *_strcpy(char *dest, char *src)
{
int i;
for (i = 0; src[i] != '\0'; i++)
{
dest[i] = src[i];
}
dest[i] = src[i];
return (dest);
}
/**
* _strlen - gets character string
*
* @s: character to get string
* Return: returns length
*/
int _strlen(char *s)
{
int i;
for (i = 0; s[i] != '\0'; i++)
{}
return (i);
}
/**
* _strcmp - Write a function that compares two strings.
*
* @s1: This is the input string
* @s2: This is the input string
*
* Return: If the strings are equals return "0", if not return other number
*/
int _strcmp(char *s1, char *s2)
{
for (; (*s1 != '\0' && *s2 != '\0') && (*s1 == *s2); s1++, s2++)
;
if (*s1 == *s2)
{
return (0);
}
return (*s1 - *s2);
}
/**
* _putchar - writes the character c to stdout
* @c: The character to print
*
* Return: On success 1.
* On error, -1 is returned, and errno is set appropriately.
*/
int _putchar(char c)
{
return (write(1, &c, 1));
}
/**
* _puts - puts a string
*
* @str: string to print
*/
void _puts(char *str)
{
int i;
for (i = 0; *(str + i) != '\0'; i++)
{
_putchar(*(str + i));
}
_putchar('\n');
}