-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmystring.h
34 lines (24 loc) · 998 Bytes
/
mystring.h
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
//
// Created by liushan on 18-8-15.
//
#include <stdbool.h>
#ifndef DAGAMA_TOOL_H
#define DAGAMA_TOOL_H
#define MAX_STR_SPLIT_SIZE 4096
bool str_endwith(const char * str, const char * cmp_str);
bool str_startwith(const char * str, const char * cmp_str);
bool str_isspace(const char * str);
// 返回截断的空白字符数
int str_rstrip(char * str);
int str_lstrip(char * str);
int str_strip(char * str);
// 字符串分割成数组
// 例如: 10.10.10.10, 10.10.10.2 分割为["10.10.10.10", "10.10.10.2"]
// 返回生成的数组长度
int str_split(const char *str_ori, char ch_split, char str_tgt[][MAX_STR_SPLIT_SIZE], int ch_num);
int str_split2(const char *str_ori, char ch_split, char * * str_tgt, int len1, int len2);
char * str_join(char * ch_split, int split_len,
char str_ori[][MAX_STR_SPLIT_SIZE], int ch_num, char * str_tgt, int str_tgt_len);
int str_lstrip_str(char * dest, const char * str_match);
void test_haha(char * ptr);
#endif //DAGAMA_TOOL_H