Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 10 / strings.cpp
diff options
context:
space:
mode:
Commit9b7e0799a1ac46819e891d33f6a51c2aba171475 (patch)
Author
 Angel Dimitriev <achi_d@abv.bg>
2020-12-19 09:58:06 -0500
Committer
 GitHub <noreply@github.com>
2020-12-19 09:58:06 -0500
Filesbf772bbfad5341da4ee26dc55eb8e990c38f7fbe /Sem. 10/strings.cpp
Introduction_to_programming_FMI-9b7e0799a1ac46819e891d33f6a51c2aba171475.tar
Introduction_to_programming_FMI-9b7e0799a1ac46819e891d33f6a51c2aba171475.tar.gz
Introduction_to_programming_FMI-9b7e0799a1ac46819e891d33f6a51c2aba171475.zip
Parent967283a4f1946ec167440557f5599f799c69cae7 (diff)
Update strings.cpp
1 files changed, 4 insertions, 3 deletions
-rw-r--r--Sem. 10/strings.cpp7
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()
{