Can I output strings using core.stdc.stdio?

Godnyx rempas at tutanota.com
Wed Dec 23 12:24:41 UTC 2020


On Wednesday, 23 December 2020 at 09:42:42 UTC, Ferhat Kurtulmuş 
wrote:
> 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);
>     }
> }

This method works but I won't let me use arguments other than 
string. Ali gave a solution that will solve this limitation! See 
me reply below!


More information about the Digitalmars-d-learn mailing list