import core.stdc.stdio: putc, stdout;
void print(T...)(string prompt, T args)
{
foreach (a; args)
{
alias A = typeof(a);
static if (is(A : string))
{
for (int j = 0; j < a.length; j++)
{
putc(a[j], stdout);
}
}
else
{
// handle your other types
print("", A.stringof);
}
}
}
void main()
{
print("Prompt (ignored)", "Hello", " world!\n", 123);
}
d
版打印