[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strcat and spaces?
From: |
Ben Abbott |
Subject: |
Re: strcat and spaces? |
Date: |
Wed, 26 Nov 2008 10:54:56 -0500 |
On Wednesday, November 26, 2008, at 09:13AM, "Soren Hauberg" <address@hidden>
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?
>
>Soren
>
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