-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstr_fun.c
81 lines (80 loc) · 906 Bytes
/
str_fun.c
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
int len(char *s)
{
int l = 0;
while (*s != '\0')
{
l++;
s++;
}
return (l);
}
int coun_vow(char *s)
{
int c = 0;
while (*s != '\0')
{
switch (*s)
{
case 'a':
case 'e':
case 'o':
case 'i':
case 'u':
case 'A':
case 'E':
case 'U':
case 'I':
case 'O':
c++;
break;
}
s++;
}
return c;
}
void copy(char *s, char *t)
{
while (*s != '\0')
{
*t = *s;
t++;
s++;
}
*t = '\0';
}
void add(char *t, char *s)
{
while (*t != '\0')
t++;
while (*s != '\0')
{
*t = *s;
s++;
t++;
}
*t = '\0';
}
int comp(char *t, char *s)
{
int c;
while (*t != '\0')
{
c = *s - *t;
s++;
t++;
}
return c;
}
char *rev(char *s)
{
char t;
int i, l;
l = len(s);
for (i = 0; i < l / 2; i++)
{
t = *(s + i);
*(s + i) = *(s + l - 1 - i);
*(s + l - 1 - i) = t;
}
return (s);
}