Re: printf, writeln, writefln

2022-12-18 Thread j via Digitalmars-d-learn
On Sunday, 18 December 2022 at 16:17:40 UTC, Salih Dincer wrote: On Saturday, 10 December 2022 at 11:13:57 UTC, Nick Treleaven wrote: It was bizarre and confusing that assignment syntax was implemented for functions and methods not explicitly marked with @property. Hi Nick, do you think this

Re: printf, writeln, writefln

2022-12-18 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 10 December 2022 at 11:13:57 UTC, Nick Treleaven wrote: It was bizarre and confusing that assignment syntax was implemented for functions and methods not explicitly marked with @property. Hi Nick, do you think this is confusing? ```d void main() { struct S { int value;

Re: printf, writeln, writefln

2022-12-10 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 8 December 2022 at 17:39:58 UTC, Ali Çehreli wrote: On 12/8/22 08:21, Salih Dincer wrote: > void stringCopy(Chars)(string source, > ref Chars target) >sample.stringCopy = cTxt; // disappeared ? char Nothing disappeared on my system. (?) Going off-topic,

Re: printf, writeln, writefln

2022-12-08 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 8 December 2022 apt 17:39:58 UTC, Ali Çehreli wrote: > ```d > void stringCopy(Chars)(string source, > ref Chars target) > >sample.stringCopy = cTxt; // disappeared ? char > ``` I find the expression above extremely confusing. I am used to assignment

Re: printf, writeln, writefln

2022-12-08 Thread Ali Çehreli via Digitalmars-d-learn
On 12/8/22 08:21, Salih Dincer wrote: > void stringCopy(Chars)(string source, > ref Chars target) >sample.stringCopy = cTxt; // disappeared ? char Nothing disappeared on my system. (?) Going off-topic, I find the expression above extremely confusing. I am used to

Re: printf, writeln, writefln

2022-12-08 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 6 December 2022 at 23:41:09 UTC, H. S. Teoh wrote: On Tue, Dec 06, 2022 at 11:07:32PM +, johannes via Digitalmars-d-learn wrote: //-- the result should be f.i. "the sun is shining" //-- sqlite3_column_text returns a constant char* a \0 delimited c-string

Re: printf, writeln, writefln

2022-12-08 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 6 December 2022 at 23:41:09 UTC, H. S. Teoh wrote: On Tue, Dec 06, 2022 at 11:07:32PM +, johannes via Digitalmars-d-learn wrote: //-- the result should be f.i. "the sun is shining" //-- sqlite3_column_text returns a constant char* a \0 delimited c-string

Re: printf, writeln, writefln

2022-12-08 Thread johannes via Digitalmars-d-learn
Thank you all for those explanations. Helps a lot!

Re: printf, writeln, writefln

2022-12-07 Thread Ali Çehreli via Digitalmars-d-learn
On 12/6/22 15:07, johannes wrote: > 'write' prints out the address > of the first byte. This is odd to me because printf does the job > correctly. printf behaves as what you expect because %s means dereferencing the pointer values and printing the char contents until printf sees '\0'. > But

Re: printf, writeln, writefln

2022-12-06 Thread ag0aep6g via Digitalmars-d-learn
On 07.12.22 01:35, ryuukk_ wrote: On Tuesday, 6 December 2022 at 23:41:09 UTC, H. S. Teoh wrote: [...] In D, strings are not the same as char*.  You should use std.conv.fromStringZ to convert the C char* to a D string. [...] no, you don't "need" to use std conv Here is an alternative that

Re: printf, writeln, writefln

2022-12-06 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 7 December 2022 at 01:46:21 UTC, Siarhei Siamashka wrote: On Tuesday, 6 December 2022 at 23:07:32 UTC, johannes wrote: //-- the result should be f.i. "the sun is shining" //-- sqlite3_column_text returns a constant char* a \0 delimited c-string

Re: printf, writeln, writefln

2022-12-06 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 6 December 2022 at 23:07:32 UTC, johannes wrote: //-- the result should be f.i. "the sun is shining" //-- sqlite3_column_text returns a constant char* a \0 delimited c-string printf("%s\n",sqlite3_column_text(res, i)); writeln(sqlite3_column_text(res, i));

Re: printf, writeln, writefln

2022-12-06 Thread ryuukk_ via Digitalmars-d-learn
On Tuesday, 6 December 2022 at 23:41:09 UTC, H. S. Teoh wrote: On Tue, Dec 06, 2022 at 11:07:32PM +, johannes via Digitalmars-d-learn wrote: //-- the result should be f.i. "the sun is shining" //-- sqlite3_column_text returns a constant char* a \0 delimited c-string

Re: printf, writeln, writefln

2022-12-06 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 06, 2022 at 11:07:32PM +, johannes via Digitalmars-d-learn wrote: > //-- the result should be f.i. "the sun is shining" > //-- sqlite3_column_text returns a constant char* a \0 delimited c-string > printf("%s\n",sqlite3_column_text(res, i)); > writeln(sqlite3_column_text(res, i));

printf, writeln, writefln

2022-12-06 Thread johannes via Digitalmars-d-learn
//-- the result should be f.i. "the sun is shining" //-- sqlite3_column_text returns a constant char* a \0 delimited c-string printf("%s\n",sqlite3_column_text(res, i)); writeln(sqlite3_column_text(res, i)); writefln("%s",sqlite3_column_text(res, i));