From 7bf09994cf0e7a67d5e3c54990117dcdcda9e614 Mon Sep 17 00:00:00 2001 From: mpabi Date: Sun, 26 May 2024 07:41:50 +0000 Subject: [PATCH] update --- cpp/_rvmain.cpp | 7 +------ cpp/myfunc.cpp | 13 +++++++++++++ cpp/myfunc.h | 6 ++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cpp/_rvmain.cpp b/cpp/_rvmain.cpp index 338a5e7..f55b304 100644 --- a/cpp/_rvmain.cpp +++ b/cpp/_rvmain.cpp @@ -1,4 +1,5 @@ #include +#include "myfunc.h" int strlen(char *s) { char *p = s; @@ -51,12 +52,6 @@ char *alloc(int n) //pre processor #define LEN (8+2)*10 -struct model { - char * ptr; - uint32_t len ; -}; - - //alg // prosta implementacji func. z bibl. std. strok przy uzyciu gpt3.5 // diff --git a/cpp/myfunc.cpp b/cpp/myfunc.cpp index c0ef119..7d865b6 100644 --- a/cpp/myfunc.cpp +++ b/cpp/myfunc.cpp @@ -1,4 +1,17 @@ #include "myfunc.h" +#include + +int strncmp(const char* s1, const char* s2, size_t n) { + for (size_t i = 0; i < n; i++) { + if (s1[i] != s2[i]) { + return (unsigned char)s1[i] - (unsigned char)s2[i]; + } + if (s1[i] == '\0' || s2[i] == '\0') { + break; + } + } + return 0; +} bool compareWords(const char* a, int lenA, const char* b, int lenB) { int minLen = (lenA < lenB) ? lenA : lenB; diff --git a/cpp/myfunc.h b/cpp/myfunc.h index 99a5984..a18943c 100644 --- a/cpp/myfunc.h +++ b/cpp/myfunc.h @@ -3,7 +3,9 @@ #include - -void count_characters(const char* alfabet, const char* slowo, uint8_t* wynik); +struct model { + char * ptr; + uint32_t len ; +}; #endif