Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 13:06:37 UTC, drug wrote: On 12/23/20 3:23 PM, Godnyx wrote: Any ideas? Just fix your typos: ```D import std : printf, toStringz; void put(A...)(string prompt, A args) { static foreach (ulong i; 0..args.length) { static if (is(typeof(args[i]) ==

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 13:55:20 UTC, Adam D. Ruppe wrote: On Wednesday, 23 December 2020 at 13:06:37 UTC, drug wrote: static foreach (ulong i; 0..args.length) { static if (is(typeof(args[i]) == string)) printf("%s\n", args[i].toStringz); static if (is(t

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
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

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 09:50:03 UTC, Ali Çehreli wrote: On 12/23/20 1:06 AM, Godnyx wrote: > for (ulong i = 0; i < args.length; i++) { > if (typeof(args[i]).stringof == "string") > printf("%s\n", args[i].toStringz); > } I replaced for with foreach and

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 08:50:50 UTC, Mike Parker wrote: On Wednesday, 23 December 2020 at 08:45:15 UTC, Godnyx wrote: Yep and I find it out! It won't work with templates and/or variadic function parameters. It says that the variable can't be read at compile time (so I can't cast it)

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 04:02:54 UTC, Paul Backus wrote: On Tuesday, 22 December 2020 at 21:26:37 UTC, Godnyx wrote: On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote: Is there a way? If not then how std.stdio does it? I should mention that I want to use it in a variable th

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 21:40:15 UTC, Dave P. wrote: On Tuesday, 22 December 2020 at 21:37:23 UTC, Godnyx wrote: On Tuesday, 22 December 2020 at 21:28:10 UTC, Dave P. wrote: On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote: [...] Lol. Actually I just don't want to use Phobos

Re: Can I output strings using core.stdc.stdio?

2020-12-22 Thread Godnyx via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 21:28:10 UTC, Dave P. wrote: On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote: Is there a way? If not then how std.stdio does it? I assume you’re asking this because you don’t have access to std.stdio (such as using betterC). The way to do it is to

Re: Can I output strings using core.stdc.stdio?

2020-12-22 Thread Godnyx via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote: Is there a way? If not then how std.stdio does it? I should mention that I want to use it in a variable that can't be read at compile time so .toStringz is not working for me.

Can I output strings using core.stdc.stdio?

2020-12-22 Thread Godnyx via Digitalmars-d-learn
Is there a way? If not then how std.stdio does it?

Re: C++ or D?

2020-12-19 Thread Godnyx via Digitalmars-d-learn
On Thursday, 12 November 2020 at 09:35:10 UTC, hgriffin wrote: C++ is a really overloaded with features language. The burden of backward compatibility and source compatibility with C doesn't make it any better. But right now it's the only right choice for development. There are plenty of librar

Re: Can I convert string to expression somehow?

2020-12-12 Thread Godnyx via Digitalmars-d-learn
On Saturday, 12 December 2020 at 11:03:06 UTC, Tobias Pankrath wrote: On Saturday, 12 December 2020 at 09:05:19 UTC, Godnyx wrote: I'm trying to create a cool function that will let us do formatting sorter and faster. The function will work like that: outln("My name is {name} and my age is {ag

Can I convert string to expression somehow?

2020-12-12 Thread Godnyx via Digitalmars-d-learn
I'm trying to create a cool function that will let us do formatting sorter and faster. The function will work like that: outln("My name is {name} and my age is {age}"); this will be equivalent to: writeln("My name is ", name, " and my age is ", age); or: writefln("My name is %s and my age is