-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.cpp
More file actions
38 lines (30 loc) · 706 Bytes
/
util.cpp
File metadata and controls
38 lines (30 loc) · 706 Bytes
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
#include "util.h"
int strlen_(char *str) {
int len = 0;
while (str[len] != '\n' && str[len])
len++;
return len;
}
void str_lower(char *str) {
int index = 0;
while (str[index]) {
if (str[index] >= 'A' && str[index] <= 'B')
str[index] = (str[index] - 'A') + 'a';
index++;
}
}
int str_compare(char *str1, char *str2) {
int index = 0;
while (str1[index] && str2[index]) {
if (str1[index] != str2[index])
return 0;
index++;
}
if (!str1[index] && !str2[index])
return 1;
return 0;
}
void fillString(char *str, int len, char val) {
for (int i = 0; i < len; i++)
str[i] = val;
}