(char* str) is not callable using argument types (string)
Shachar Shemesh via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jul 17 20:58:49 PDT 2017
On 07/17/2017 05:10 PM, Adam D. Ruppe wrote:
> On Monday, 17 July 2017 at 13:56:24 UTC, Zaheer Ahmed wrote:
>> I Developed OS in C and C++ but first time stuck in types.
>
> A lot of C and C++ knowledge will carry over to D, but it isn't exactly
> the same. D's strings are of type `string` which is another word for
> `immutable(char)[]`.
>
> immutable means the contents never change. A `[]` slice is a
> pointer+length pair in a single type.
>
>
> For your simple case, making it `const char*` should work...
No, it shouldn't.
Worst, it should work *most* of the time.
If you cast a D string to const char* may or may not null terminate the
string.
Shachar
More information about the Digitalmars-d
mailing list