* follow #8463 #14157 and document cstring literals * Update doc/manual.rst Co-authored-by: Juan Carlos <juancarlospaco@gmail.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
parent
cc882917fe
commit
4663319bf5
1 changed files with 14 additions and 0 deletions
|
|
@ -1280,6 +1280,20 @@ string from a cstring:
|
||||||
var cstr: cstring = str
|
var cstr: cstring = str
|
||||||
var newstr: string = $cstr
|
var newstr: string = $cstr
|
||||||
|
|
||||||
|
``cstring`` literals shouldn't be modified.
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
var x = cstring"literals"
|
||||||
|
x[1] = 'A' # This is wrong!!!
|
||||||
|
|
||||||
|
If the ``cstring`` originates from a regular memory (not read-only memory),
|
||||||
|
it can be modified:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
var x = "123456"
|
||||||
|
var s: cstring = x
|
||||||
|
s[0] = 'u' # This is ok
|
||||||
|
|
||||||
Structured types
|
Structured types
|
||||||
----------------
|
----------------
|
||||||
A variable of a structured type can hold multiple values at the same
|
A variable of a structured type can hold multiple values at the same
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue