-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter_utils.c
More file actions
116 lines (96 loc) · 1.56 KB
/
Copy pathcharacter_utils.c
File metadata and controls
116 lines (96 loc) · 1.56 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "main.h"
/**
*_strncpy - fucntion append two string to one
*@dest: string copied to
*@src: string copied from
*@n:buffer
*Return: string of characters
*/
char *_strncpy(char *dest, const char *src, size_t n)
{
char *dest_start = dest;
while (*src && n > 0)
{
*dest++ = *src++;
n--;
}
while (n > 0)
{
*dest++ = '\0';
n--;
}
return (dest_start);
}
/**
*_isdigit - checks if character is num
*@c: character
*Return: should not return NULL for success
*/
int _isdigit(int c)
{
return (c >= '0' && c <= '9');
}
/**
*isNumber - checks if string is number
*@str: string to examened
*Return: should return 0 for success
*/
int isNumber(char *str)
{
int i = 0;
if (str[i] == '-')
i++;
for (; str[i] != '\0'; i++)
{
if (!_isdigit(str[i]))
return (0);
}
return (1);
}
/**
*_strtok - tokenize string
*@str: pointer to string to tokenized
*@del: delimeters
*Return: pointer to token
*/
char *_strtok(char *str, char *del)
{
static char *next_token /*= NULL*/;
char *token;
if (str != NULL)
next_token = str;
if (next_token == NULL || *next_token == '\0')
return (NULL);
token = next_token;
next_token = _strpbrk(next_token, del);
if (next_token != NULL)
{
*next_token = '\0';
next_token++;
}
return (token);
}
/**
*_strpbrk - function gets length of prefix substring.
*@s: string s
*@accept: string
*Return: should returns smtg
*/
char *_strpbrk(char *s, char *accept)
{
char *a;
while (*s)
{
a = accept;
while (*a)
{
if (*s == *a)
{
return (s);
}
a++;
}
s++;
}
return ('\0');
}