From f9a5352b6e6752375cd3520b28da474285288768 Mon Sep 17 00:00:00 2001 From: justuser-31 Date: Sun, 4 May 2025 21:11:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D0=B2=D0=B5=D1=80=D1=82?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D1=87=D0=B8=D1=81=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D1=85=20=D1=82=D0=B8=D0=BF=D0=BE=D0=B2=20=D0=B2=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/string.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libs/string.h b/libs/string.h index dde6c47..bd24e24 100644 --- a/libs/string.h +++ b/libs/string.h @@ -1,12 +1,23 @@ #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); @@ -18,3 +29,26 @@ void strSet(string* s, char* 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(12); + sprintf(buffer, "%f", *num); + return buffer; +} +char* double2Str(double* num) { + char* buffer = malloc(12); + sprintf(buffer, "%f", *num); + return buffer; +} +// -------------- END ------------------