Thread overview |
---|
September 04, 2003 from char* to char[] | ||||
---|---|---|---|---|
| ||||
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 |
September 04, 2003 Re: from char* to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to manfred | <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)]; |
September 04, 2003 Re: from char* to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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)]; > > |
Copyright © 1999-2021 by the D Language Foundation