From 9b7e0799a1ac46819e891d33f6a51c2aba171475 Mon Sep 17 00:00:00 2001 From: Angel Dimitriev Date: Sat, 19 Dec 2020 09:58:06 -0500 Subject: Update strings.cpp --- Sem. 10/strings.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Sem. 10/strings.cpp') diff --git a/Sem. 10/strings.cpp b/Sem. 10/strings.cpp index 5284e99..bf0559f 100644 --- a/Sem. 10/strings.cpp +++ b/Sem. 10/strings.cpp @@ -7,9 +7,9 @@ using namespace std; // k за текста и една клетка за \0; -const int LEN = 300; + // Функцията ще променя ли масива? -// Ако не - const!!! +// Ако не, винаги слагаме const! int stringLength(const char* str) { @@ -77,10 +77,11 @@ void stringConcat(char* dest, const char* source) int destLength = stringLength(dest); int sourceLength = stringLength(source); - for (int i = 0; i <= sourceLength; i++) + for (int i = 0; i <= sourceLength; i++) // Тук използваме <= за да вземем и терминиращата нула от source. dest[destLength + i] = source[i]; } +const int LEN = 300; int main() { -- cgit v1.3.1-23-gd82d