#include #include #include // ------------------------------------- // BASE - String and init of this // ------------------------------------- typedef char* string; string strInit(char* s) { string str = malloc(strlen(s) * sizeof(char)); strcpy(str, s); return str; } // -------------- END ------------------ // ------------------------------------- // FUNCTION - basic operations // ------------------------------------- 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); } // -------------- END ------------------ // ------------------------------------- // CONVERT - different convert to str // ------------------------------------- char* int2Str(int* num) { char* buffer = malloc(12); sprintf(buffer, "%d", *num); return buffer; } char* float2Str(float* num) { char* buffer = malloc(41); sprintf(buffer, "%f", *num); return buffer; } char* double2Str(double* num) { char* buffer = malloc(311); sprintf(buffer, "%f", *num); return buffer; } // -------------- END ------------------