digitalmars.D.learn - Storing Formatted Array Value
- Vino (19/19) Nov 28 2017 Hi All,
- Petar Kirov [ZombineDev] (16/35) Nov 28 2017 https://dlang.org/phobos/std_format is your friend:
Hi All, Request your help, with the below code I am able to print the value of the array without brackects , but can some on help me on hot to store this output to a variable Program: import std.stdio; import std.container; void main() { auto test = Array!string("Test1", "Test2"); writefln("%(%s, %)",test[]); // output : "Test1", "Test2" // Similar like this auto res = `writefln("%(%s, %)",test[])`; writeln(res); } Output of res should look like : "Test1", "Test2" (Without [] brackets). From, Vino.B
Nov 28 2017
On Wednesday, 29 November 2017 at 07:08:12 UTC, Vino wrote:Hi All, Request your help, with the below code I am able to print the value of the array without brackects , but can some on help me on hot to store this output to a variable Program: import std.stdio; import std.container; void main() { auto test = Array!string("Test1", "Test2"); writefln("%(%s, %)",test[]); // output : "Test1", "Test2" // Similar like this auto res = `writefln("%(%s, %)",test[])`; writeln(res); } Output of res should look like : "Test1", "Test2" (Without [] brackets). From, Vino.Bhttps://dlang.org/phobos/std_format is your friend: // https://run.dlang.io/is/sUkOX0 import std.container; import std.format; import std.stdio; void main() { auto test = Array!string("Test1", "Test2"); writefln("%(%s, %)",test[]); // Similar like this auto res = "%(%s, %)".format(test[]); writeln(res); auto res2 = "%-(%s, %)".format(test[]); writeln(res2); }
Nov 28 2017