diff options
| author | Aleksa Vučković <aleksav013@gmail.com> | 2021-10-12 21:53:40 +0200 |
|---|---|---|
| committer | Aleksa Vučković <aleksav013@gmail.com> | 2021-10-12 21:53:40 +0200 |
| commit | 4528b2347ac72ffdabdbe4d9e7bf7789c81e664f (patch) | |
| tree | 7a5b14e228d858def22d0b5bfcffba69c4e5879e /src/string.c | |
| parent | 578d467b80015c52d0c96c8443b4c13936f33365 (diff) | |
Adding tty
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c new file mode 100644 index 0000000..4683470 --- /dev/null +++ b/src/string.c @@ -0,0 +1,34 @@ +#include<stdbool.h> +#include<stddef.h> +#include<stdint.h> + +bool stringcmp(char *str1,char *str2) +{ + size_t i; + for(i=0;str1[i]||str2[i];i++) if(str1[i]!=str2[i]) return 0; + if(str1[i]==str2[i]) return 1; + return 0; +} + +size_t pieces(char pieces[15][15],char *buffer) +{ + for(size_t x=0;x<15;x++) for(size_t y=0;y<15;y++) pieces[x][y]='\0'; + + size_t i=0,j=0,r=0; + while(buffer[i]==' '&&buffer[i]!='\0') i++; + for(;buffer[i]!='\0';i++) + { + if(buffer[i]==' ') + { + while(buffer[i]==' '&&buffer[i]!='\0') i++; + j=0; + r++; + i--; + } + else + { + pieces[r][j++]=buffer[i]; + } + } + return r+1; +} |
