From d769c253e8a6ddc67cf8424da2017d309e93f11b Mon Sep 17 00:00:00 2001 From: amy Date: Fri, 14 Apr 2023 13:22:32 +0000 Subject: init --- src/strings.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/strings.h (limited to 'src/strings.h') diff --git a/src/strings.h b/src/strings.h new file mode 100644 index 0000000..7a6fb08 --- /dev/null +++ b/src/strings.h @@ -0,0 +1,29 @@ +#include +#include +#ifndef __str__ +#define __str__ +//#define init_str(buffer) (buffer); \ + {buffer = (char*)malloc(sizeof(char));\ + buffer[0]='\0';} +//#define str_size(str,sizeb) (sizeb); \ + for(sizeb=0;;sizeb++)if(str[sizeb]=='\0')break; +//#define str_push(str,ch)\ + int size_y = str_size(str);\ + str = (char*)realloc(str,sizeof(char*)*(size_y+1));\ + str[size_y]=ch;\ + str[size_y+1]='\0'; +typedef struct { + char*str; + int len; +}str; +str* str_init(); +int str_size(str*str); +int ca_size(char*str); +void str_pushc(str*str,char ch); +void str_pushca(str*str,char*ins); +int str_cmp_str(str*,str*); +int str_cmp_ca(str*,char*); +void str_free(str*str); +str* str_init_only_str(str*str); +void str_clear(str*str); +#endif -- cgit v1.2.3