-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.c
57 lines (49 loc) · 815 Bytes
/
string.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <assert.h>
#include "string.h"
struct STRING
{
char *value;
};
STRING *
newSTRING(char *x)
{
STRING *p = malloc(sizeof(STRING));
assert(p != 0);
p->value = x;
return p;
}
char *
getSTRING(STRING *v)
{
return v->value;
}
char *
setSTRING(STRING *v,char *x)
{
char *old = v->value;
v->value = x;
return old;
}
void
displaySTRING(void *v,FILE *fp)
{
fprintf(fp,"%s",getSTRING((STRING *) v));
}
int
compareSTRING(void *v,void *w)
{
return strcmp(getSTRING((STRING *) v), getSTRING((STRING *) w));
}
int
rcompareSTRING(void *v,void *w) {
return compareSTRING(w,v);
}
void
freeSTRING(void *v)
{
free((STRING *) v);
}