Copy a string: Difference between revisions

m
Spelling/grammar/aesthetics and removed an extra category tag
m (Spelling/grammar/aesthetics and removed an extra category tag)
Line 1:
{{task}}
This task is about copying a string. Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string.
 
=={{header|Ada}}==
Line 104:
 
=={{header|C sharp|C #}}==
[[Category:C sharp]]
string src = "Hello";
string dst = src;
Line 125 ⟶ 124:
=={{header|Factor}}==
 
Factor strings are mutable but not growable. Strings will be immutable in a future release.
 
"This is a mutable string." dup ! reference
Line 140 ⟶ 139:
 
SBUF" I'll be a string someday." >string .
"I'll be a string somdaysomeday."
 
=={{header|Forth}}==
 
Forth strings are generally stored in memory as prefix counted string, where the first byte contains the string length. However, on the stack they are most often represented as <addr cnt> pairs. Thus the way you copy a string depends on where the source string comes from:
 
\ Allocate two string buffers
Line 191 ⟶ 190:
=={{header|Pop11}}==
 
In Pop11 normal data are represented by references, so plain assignment will copy references. To copy data one has to use copy procedure:
will copy references. To copy data one has to use copy procedure:
 
vars src, dst;
Anonymous user