-
Notifications
You must be signed in to change notification settings - Fork 0
/
str.h
60 lines (49 loc) · 1.28 KB
/
str.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
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
/*
* Project: Compiler for imperative programing language IFJ20
*
* File: str.h
* Brief: Dynamic string file
* Source: Jednoduchy interpret - http://www.fit.vutbr.cz/study/courses/IFJ/public/project/
*
* Authors: Hladký Tomáš xhladk15@stud.fit.vutbr.cz
* Kostolányi Adam xkosto04@stud.fit.vutbr.cz
* Makiš Jozef xmakis00@stud.fit.vutbr.cz
* Bartko Jakub xbartk07@stud.fit.vutbr.cz
*/
#ifndef IFJ_BHKM_STR_H
#define IFJ_BHKM_STR_H
#define STR_LEN_INC 8 // initial allocated size for char
typedef struct {
char *str; // pointer to string ended with '\0'
int str_lenght; // string lenght
int str_alloc_size; // size of allocated memory
} string;
/*
* Function creates new string.
*/
void str_init(string *s);
/*
* Function frees allocated memory
*/
void str_free(string *s);
/*
* Function clears string array.
*/
void str_clear(string *s);
/*
* Function adds new char into string array.
*/
void str_add_char(string *s, char c);
/*
* Function copies second string into the first.
*/
void str_copy(string *s1, string *s2);
/*
* Function compares string with constant.
*/
int str_cmp_cons(string *s, char *s_const);
/*
* Function comapares two strings.
*/
int str_cmp(string *s1, string *s2);
#endif //IFJ_BHKM_STR_H