diff options
Autocommit at 07.05.2022 @ 10:47
2 files changed, 10 insertions, 3 deletions
| -rw-r--r-- | src/Generic/String/String.cpp | 11 | ||||
| -rw-r--r-- | src/Generic/String/String.h | 2 |
diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index b1e2889..570a2c6 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -9,16 +9,17 @@ void String::free() { void String::copyFrom(const String& other) { str = new char[other.length]; - strcpy(str, other.str); + strncpy(str, other.str, other.count); length = other.length; + count = other.count; } /* Public */ String::String(const char* str) { - length = strlen(str) + 1; // capture terminating zero + count = length = strlen(str) + 1; // capture terminating zero this->str = new char[length]; - strncpy(this->str, str, length); + strncpy(this->str, str, count); } const char* String::get_cstr() const { @@ -37,6 +38,10 @@ String& String::operator+=(const String& other) { return *this; } +String& String::operator+=(char other) { + if () +} + String::String() : String("") {} String::String(const String& other) { diff --git a/src/Generic/String/String.h b/src/Generic/String/String.h index 236a3e4..cefb05d 100644 --- a/src/Generic/String/String.h +++ b/src/Generic/String/String.h @@ -6,6 +6,7 @@ class String { unsigned count; unsigned length; + void resize(); void free(); void copyFrom(const String& other); @@ -14,6 +15,7 @@ public: const char* get_cstr() const; String& operator+=(const String& other); + String& operator+=(char character); String(); String(const String& other); |
