printf, writeln, writefln
johannes
johannes.janssens at yahoo.com
Tue Dec 6 23:07:32 UTC 2022
//-- 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));
writefln(std.conv.to!string(sqlite3_column_text(res, i)));
//-- the result :
the sun is shining
55B504B3CE98
55B504B3CE98
the sun is shining
=> without 'std.conv.to!string' I presume 'write' prints out the
address of the first byte. This is odd to me because printf does
the job correctly. But I think to understand that write in D
interpretes char* as a pointer to a byte. So it prints the
address that the pointer points to.(?)
So the question : for every c funtion returning char* I will have
to use std.conv.to!string(..) or is there another way. Also it
seems the formatting "%s" has another meaning in D ?
More information about the Digitalmars-d-learn
mailing list