3 string::string(char *text
) {
4 data
= new char[strlen(text
)];
7 string::string() : data((char*)0) {}
14 int string::length() const {
18 char &string::operator[](int index
) {
25 bool string::operator==(char *x
) {
32 bool string::operator==(string
&x
) {
33 if (!strcmp(data
, x
.data
))
39 string::operator char*() {
43 int strlen(const char *a
) {
45 for (i
= 0; a
[i
]; i
++);
49 int strcmp(const char *a
,const char *b
) {
51 for (i
= 0; a
[i
] && b
[i
] && a
[i
] == b
[i
]; i
++);
52 if (a
[i
] != b
[i
]) return 1;
56 int strncmp(const char *a
,const char *b
, int n
) {
58 for (i
= 0; a
[i
] && b
[i
] && a
[i
] == b
[i
] && i
< n
; i
++);
59 if (a
[i
] != b
[i
] && i
!= n
) return 1;
63 char *strcat(char *a
, const char *b
) {
64 return strcpy(&(a
[strlen(a
)]), b
);
67 char *strcpy(char *a
, const char *b
) {
68 return (char*)memcpy((void*)a
, (const void *)b
, strlen(b
));
71 void *memcpy(void * a
, const void * b
, int count
) {
72 for (int i
= 0; i
< count
; i
++)
73 ((char *)a
)[i
] = ((const char *)b
)[i
];
77 void *memset(void *a
, int sign
, int count
) {
78 for (int i
= 0; i
< count
; i
++)
79 ((unsigned char *)a
)[i
] = (unsigned char)sign
;