How to make a formatted string ?
Gabriel Laskar
gabriel at lse.epita.fr
Wed Mar 17 09:21:24 PDT 2010
On 03/17/2010 02:58 PM, Lars T. Kyllingstad wrote:
> char[][] a = ["hello %s %s world".dup, "foo".dup, "bar".dup];
> string fmt = format(a[0], a[1 .. $]);
> // fmt is now "hello foo bar world"
I have another problem :
1 import std.stdio;
2 import std.string;
3
4 int main()
5 {
6 char[][] a = ["expected %s but found %s".dup, "42".dup, "32".dup];
7
8 writeln(format(a[0], a[1 .. $]));
9
10 return 0;
11 }
Does not work :
$ dmd-phobos -run format.d
std.format.FormatError: std.format
but :
1 import std.stdio;
2 import std.string;
3
4 int main()
5 {
6 char[][] a = ["expected %s".dup, "42".dup];
7
8 writeln(format(a[0], a[1 .. $]));
9
10 return 0;
11 }
does not seems to work either :
$ dmd-phobos -run format.d
expected [42]
Did I miss something ?
--
Gabriel Laskar <gabriel at lse.epita.fr>
More information about the Digitalmars-d-learn
mailing list