www.digitalmars.com         C & C++   DMDScript  

D - from char* to char[]

reply manfred toppoint.de writes:
Hello,

int main() {
char[] string;
char *query = "Test";
printf("query = %s \n",query);
string = *cast(char[]*)query;      //how to cast ?
//strcpy(string,cast(char[]*)query);
printf("string = %.*s \n",string);
printf("\n");
return 0;
}

When i start the programm the variable string didn't print "Test" .

Manfred Hansen
Sep 03 2003
parent reply "Walter" <walter digitalmars.com> writes:
<manfred toppoint.de> wrote in message
news:bj6mcg$2cnk$1 digitaldaemon.com...
 Hello,

 int main() {
 char[] string;
 char *query = "Test";
 printf("query = %s \n",query);
 string = *cast(char[]*)query;      //how to cast ?
 //strcpy(string,cast(char[]*)query);
 printf("string = %.*s \n",string);
 printf("\n");
 return 0;
 }

 When i start the programm the variable string didn't print "Test" .
try: import string; ... string = query[0..strlen(query)];
Sep 03 2003
parent manfred toppoint.de writes:
Yes, that what i want.
Thank you.

Manfred

In article <bj6ndl$2e47$3 digitaldaemon.com>, Walter says...
<manfred toppoint.de> wrote in message
news:bj6mcg$2cnk$1 digitaldaemon.com...
 Hello,

 int main() {
 char[] string;
 char *query = "Test";
 printf("query = %s \n",query);
 string = *cast(char[]*)query;      //how to cast ?
 //strcpy(string,cast(char[]*)query);
 printf("string = %.*s \n",string);
 printf("\n");
 return 0;
 }

 When i start the programm the variable string didn't print "Test" .
try: import string; ... string = query[0..strlen(query)];
Sep 04 2003