something weird with strerror_r
CodeSun via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jan 29 06:40:31 PST 2015
Recently, I found something really weird when I use strerror_t
function which is declared inside std.c.string.
The code snippet is listed below:
import std.c.string;
import core.stdc.errno;
void main() {
import std.stdio;
char[128] buf;
strerror_r(errno, buf.ptr, buf.sizeof);
writeln(cast(string)buf);
}
The terminal should print "Success" with errno=0, but in this
example, the result is
"��������������������������������������������������������������������������������������������������������������������������������".
I test this snippet both on Archlinux and Ubuntu 14.04.1, and the
result is same. If there is someone can help me?
I wanna know if it is my mistake or it is just a bug.
Thx!
More information about the Digitalmars-d
mailing list