From 3d029eada6c3db1e23cf13653233faef323f10f5 Mon Sep 17 00:00:00 2001 From: Animesh Srivastava Date: Thu, 18 Jul 2019 23:58:14 +0530 Subject: [PATCH 1/2] Update string.adoc --- Language/Variables/Data Types/string.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Language/Variables/Data Types/string.adoc b/Language/Variables/Data Types/string.adoc index 9273f9c9e..d05e3bae2 100644 --- a/Language/Variables/Data Types/string.adoc +++ b/Language/Variables/Data Types/string.adoc @@ -12,7 +12,7 @@ subCategories: [ "Data Types" ] [float] === Description -Text strings can be represented in two ways. you can use the String data type, which is part of the core as of version 0019, or you can make a string out of an array of type char and null-terminate it. This page described the latter method. For more details on the String object, which gives you more functionality at the cost of more memory, see the link:../stringobject[String object] page. +Text strings can be represented in two ways. you can use the String data type, which is part of the core as of version 0019, or you can make a string out of an array of type char and null-terminate it. This page described the latter method. For more details on the String object, which gives you more functionality at the cost of more memory, see the `link:../stringobject[String object]` page. [%hardbreaks] [float] @@ -37,7 +37,7 @@ All of the following are valid declarations for strings. *Null termination* -Generally, strings are terminated with a null character (ASCII code 0). This allows functions (like `Serial.print()`) to tell where the end of a string is. Otherwise, they would continue reading subsequent bytes of memory that aren't actually part of the string. +Generally, strings are terminated with a null character (ASCII code 0). This allows functions (like `link:../../../functions/communication/serial/print[Serial.print()]`) to tell where the end of a string is. Otherwise, they would continue reading subsequent bytes of memory that aren't actually part of the string. This means that your string needs to have space for one more character than the text you want it to contain. That is why Str2 and Str5 need to be eight characters, even though "arduino" is only seven - the last position is automatically filled with a null character. Str4 will be automatically sized to eight characters, one for the extra null. In Str3, we've explicitly included the null character (written '\0') ourselves. @@ -62,7 +62,7 @@ char myString[] = "This is the first line" It is often convenient, when working with large amounts of text, such as a project with an LCD display, to setup an array of strings. Because strings themselves are arrays, this is actually an example of a two-dimensional array. -In the code below, the asterisk after the datatype `char` "`char*`" indicates that this is an array of "`pointers`". All array names are actually pointers, so this is required to make an array of arrays. Pointers are one of the more esoteric parts of C++ for beginners to understand, but it isn't necessary to understand pointers in detail to use them effectively here. +In the code below, the asterisk after the datatype `link:../char[char]` "`char*`" indicates that this is an array of "`pointers`". All array names are actually pointers, so this is required to make an array of arrays. Pointers are one of the more esoteric parts of C++ for beginners to understand, but it isn't necessary to understand pointers in detail to use them effectively here. -- // OVERVIEW SECTION ENDS From 53e1e95934306639b890223f0d0f01f7941a6b29 Mon Sep 17 00:00:00 2001 From: Animesh Srivastava Date: Tue, 30 Jul 2019 15:53:42 +0530 Subject: [PATCH 2/2] Update Language/Variables/Data Types/string.adoc Co-Authored-By: per1234 --- Language/Variables/Data Types/string.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Variables/Data Types/string.adoc b/Language/Variables/Data Types/string.adoc index d05e3bae2..c19ab743e 100644 --- a/Language/Variables/Data Types/string.adoc +++ b/Language/Variables/Data Types/string.adoc @@ -12,7 +12,7 @@ subCategories: [ "Data Types" ] [float] === Description -Text strings can be represented in two ways. you can use the String data type, which is part of the core as of version 0019, or you can make a string out of an array of type char and null-terminate it. This page described the latter method. For more details on the String object, which gives you more functionality at the cost of more memory, see the `link:../stringobject[String object]` page. +Text strings can be represented in two ways. you can use the String data type, which is part of the core as of version 0019, or you can make a string out of an array of type char and null-terminate it. This page described the latter method. For more details on the String object, which gives you more functionality at the cost of more memory, see the link:../stringobject[String object] page. [%hardbreaks] [float]