Re: puts() quirk
Actually, this makes perfect sense. Strings in most C-based modern
languages are null terminated. Any bytes after the null are considered
garbage and thus not part of the string. Since Euphoria's string
handling is largely based on C routines, the first puts will see
"cat\0\0\0\n", will see the first null (\0) and will stop the string at
that point. Since it never saw the newline, it never printed it. The
same is true for your second example.
HTH,
Mike Sabal
>>> bruce_axtens at sil.org 04/23/03 04:53AM >>>
Dear List
I don't know if anyone's noticed this before ... maybe it's old news.
sequence a
sequence b
a = { 'c', 'a', 't', 0, 0, 0 }
b = "dog"
puts( 1, a & "\n" )
puts( 1, b )
This outputs
catdog
Rather than
cat
dog
As one might expect.
Indeed, if one combines the puts() into one, e.g.
puts( 1, a & "\n" & b )
then the program outputs
cat
Weird.
Bruce.
(Windows 2000 Advanced Server, Euphoria 2.4 beta, DOS32 script in a
CMD.EXE window)
TOPICA - Start your own email discussion group. FREE!
|
Not Categorized, Please Help
|
|