D - Bug?
import std.c.stdio; import std.string; int main(char[][] args) { char[] bla = "BLA"; printf(bla[0..1]); return 0; } Prints "BLA" . shouldn't it print "B" ? If I replace it with printf(bla[0..1] ~ \n); then it is OK (it prints "B") I am using v838 Cheers, Luigi
Jan 25 2004
0x4e71 wrote:import std.c.stdio; import std.string; int main(char[][] args) { char[] bla = "BLA"; printf(bla[0..1]); return 0; } Prints "BLA" . shouldn't it print "B" ? If I replace it with printf(bla[0..1] ~ \n); then it is OK (it prints "B") I am using v838 Cheers, LuigiNot a bug. D strings aren't necessarily null-terminated. printf, being a C function, expects a null-terminated string. printf(toStringz(bla[0..1])); or printf(bla[0..1] ~ \0);
Jan 25 2004