dockimbel/Red — Issue #196: Can modify bytes in a c-string argument but not assign a string
Author: PeterWAWood
Created: 2012-01-12 04:13:23+00:00
State: open

When a c-string is passed as an argument to a function, assigning a replacement string has not effect not is a compiler error )or warning) message reported. It is possible to modify a c-string by accessing individual bytes.

Example Code:

```rebol
Red/System []

f: func [
s [c-string!]
][
s: "12345"
]

s: "abcde"
print ["before f: " s lf]
f s
print ["after f: " s lf]

f2: func [
s [c-string!]
][
s/1: #"1"
s/2: #"2"
s/3: #"3"
s/4: #"4"
s/5: #"5"
]

s: "abcde"
print ["before f2: " s lf]
f2 s
print ["after f2: " s lf]
```

Output:

```

-= Red/System Compiler =-
Compiling /Users/peter/Code/Red-System/test.reds ...
Script: "Red/System IA-32 code emitter" (none)
Script: "Red/System Mach-O format emitter" (none)

...compilation time: 97 ms
...linking time: 8 ms
...output file size: 16384 bytes
before f: abcde
after f: abcde
before f2: abcde
after f2: 12345
```