manual: add a note about the terminating zero for strings; refs #5596
This commit is contained in:
parent
d1e3a7c827
commit
4e05bca96f
1 changed files with 5 additions and 0 deletions
|
|
@ -1004,6 +1004,11 @@ All string literals are of the type ``string``. A string in Nim is very
|
||||||
similar to a sequence of characters. However, strings in Nim are both
|
similar to a sequence of characters. However, strings in Nim are both
|
||||||
zero-terminated and have a length field. One can retrieve the length with the
|
zero-terminated and have a length field. One can retrieve the length with the
|
||||||
builtin ``len`` procedure; the length never counts the terminating zero.
|
builtin ``len`` procedure; the length never counts the terminating zero.
|
||||||
|
|
||||||
|
The terminating zero cannot be accessed unless the string is converted
|
||||||
|
to the ``cstring`` type first. The terminating zero assures that this
|
||||||
|
conversion can be done in O(1) and without any allocations.
|
||||||
|
|
||||||
The assignment operator for strings always copies the string.
|
The assignment operator for strings always copies the string.
|
||||||
The ``&`` operator concatenates strings.
|
The ``&`` operator concatenates strings.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue