Can I output strings using core.stdc.stdio?

Ferhat Kurtulmuş aferust at gmail.com
Wed Dec 23 09:42:42 UTC 2020


On Wednesday, 23 December 2020 at 09:40:27 UTC, Ferhat Kurtulmuş 
wrote:
> On Wednesday, 23 December 2020 at 09:06:02 UTC, Godnyx wrote:
>> [...]
>
> I didn't dive into your use case, but you should use static 
> foreach in this case:
>
> void put(A...)(string prompt, A args) {
>     static foreach (ulong i; 0..args.length) {
>         if (typeof(args[i]).stringof == "string")
>             printf("%s\n", args[i].toStringz);
>     }
> }

and better:
void put(A...)(string prompt, A args) {
     static foreach (ulong i; 0..args.length) {
         if (is(typeof(args[i]) == string))
             printf("%s\n", args[i].toStringz);
     }
}


More information about the Digitalmars-d-learn mailing list