Can someone explain why this outputs garbage values?
Dustin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 9 11:44:41 PST 2014
I'm trying to work with some c functions that make use of varargs
and I'm trying to push my d varargs to c varargs.
http://dpaste.dzfl.pl/ad08a6197963
Code:
___________________________________________________
import core.vararg;
import std.string : toStringz;
import std.c.stdio;
char[256] buffer;
void print(string format, ...)
{
char* dest = buffer.ptr;
snprintf(dest, 256UL, toStringz(fmt), _argptr);
printf(dest);
}
void main(string[] args)
{
print("%d, %d, %d\n", 1, 2, 3);
}
___________________________________________________
Output: -1080890848, 1073915632, 3
More information about the Digitalmars-d-learn
mailing list