Re: something weird with strerror_r

2015-01-31 Thread CodeSun via Digitalmars-d
On Thursday, 29 January 2015 at 15:25:09 UTC, Mike Parker wrote: On 1/29/2015 11:40 PM, CodeSun wrote: 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;

Re: something weird with strerror_r

2015-01-29 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 29 January 2015 at 14:40:32 UTC, CodeSun wrote: writeln(cast(string)buf); Casting to string is often a mistake, here it might be the problem because you didn't check for the zero terminator, so the writeln prints all the garbage at the end of the buffer too. I'd try

Re: something weird with strerror_r

2015-01-29 Thread Mike Parker via Digitalmars-d
On 1/29/2015 11:40 PM, CodeSun wrote: 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;

something weird with strerror_r

2015-01-29 Thread CodeSun via Digitalmars-d
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,