Can't assign string to char * like the docs say
Jarrett Billingsley
jarrett.billingsley at gmail.com
Wed May 13 15:44:25 PDT 2009
On Wed, May 13, 2009 at 2:28 PM, Doctor J <nobody at nowhere.com> wrote:
> Taken straight from http://www.digitalmars.com/d/1.0/arrays.html, this doesn't compile:
>
> void main()
> {
> string str = "abc";
> char* p = str; // pointer to 1st element
> }
>
> "Error: cannot implicitly convert expression (str) of type char[] to char*"
>
> I agree it shouldn't compile; I guess I'm asking why the docs say it does.
Once upon a time, it used to. But the implicit conversion from T[] to
T* was removed when it was deemed to be too easy to make mistakes
using it.
More information about the Digitalmars-d-learn
mailing list