strcat and spaces?
Ben Abbott
bpabbott at mac.com
Wed Nov 26 09:54:56 CST 2008
On Wednesday, November 26, 2008, at 09:13AM, "Søren Hauberg" <soren at hauberg.org> wrote:
>Hi All,
> If I do the following
>
> strcat ("hel", " ", "lo")
>
>I get the string "hello", but I would have expected "hel lo". It seems
>Matlab has the same behavior, so I guess this isn't a bug, but I find it
>weird. Can anybody explain why this behavior makes sense?
>
>Søren
>
That feature is a manifestation of how "cellstr" works. Specifically, all trailing spaces are trimmed.
octave:140> fprintf("\"%s\"\n",cellstr(" 1 "){1})
" 1"
Thus,
octave:141> strcat ("hel", " ", "lo")
ans = hello
octave:142> strcat ("hel", " ", " lo")
ans = hel lo
octave:143>
Ben
More information about the Octave-maintainers
mailing list