-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrarr.h
34 lines (24 loc) · 961 Bytes
/
strarr.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
/* The module implements the string array type */
#ifndef STRARR_H
#define STRARR_H
/* Output formats for string array */
#define FRMT_W "%s " /* One element - one word */
#define FRMT_L "%s\n" /* One element - one line*/
typedef char **strarr; /* Array of strings */
/* Creates empty array and returns it */
strarr strarr_init(void);
/* Adds string 'str' to array '*parr' */
void strarr_add(strarr *parr, const char *str);
/* Returns number of elements in array 'arr' */
int strarr_len(strarr arr);
/* Prints array 'arr' using given format 'format' for each element */
void strarr_print(strarr arr, const char *format);
/* Creates a copy of array 'arr' and returns it */
strarr strarr_cp(strarr arr);
/* Finds string 'str' in array 'arr';
* If there is 'str' in 'arr', returns index of it;
* Otherwise returns -1 */
int strarr_find(strarr arr, const char *str);
/* Deletes array '*parr' and sets it to NULL */
void strarr_del(strarr *parr);
#endif