c_cross_pack/libs/string.h

21 lines
468 B
C

#include <stdlib.h>
#include <string.h>
typedef char* string;
string strInit(char* s) {
string str = malloc(strlen(s) * sizeof(char));
strcpy(str, s);
return str;
}
void strAdd(string* s, char* str_new) {
*s = realloc(*s, strlen(*s) + strlen(str_new)*sizeof(char));
strcat(*s, str_new);
}
void strSet(string* s, char* str_new) {
*s = realloc(*s, strlen(str_new)*sizeof(char));
strcpy(*s, str_new);
}
void strCopy(string* s1, string* s2) {
strcpy(*s2, *s1);
}