Re: Passing string literals to C

2015-01-01 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 11:19:36 UTC, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() {

Re: Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() { writefln(%s,fromStringz(cpling(hello\0))); } or void callC() {

Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
What's best practice here? D strings are not null-terminated. char* cpling(char *s) { So toString(This i

Re: Passing string literals to C

2014-12-31 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 31 Dec 2014 11:19:35 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d

Re: Passing string literals to C

2014-12-31 Thread Mike Parker via Digitalmars-d-learn
On 12/31/2014 8:19 PM, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() {

Re: Passing string literals to C

2014-12-31 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 11:45:33 UTC, Mike Parker wrote: On 12/31/2014 8:19 PM, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char*

Re: Passing string literals to C

2014-12-31 Thread Meta via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 12:25:45 UTC, John Colvin wrote: String literals can implicitly convert to const(char)* or immutable(char)*. Neat. It doesn't appear to apply to array literals in general though... I believe this is a special case specifically for strings added for

Re: Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for the help. Laeeth