converting numbers to strings and back

dominik aha at aha.com
Sat Oct 6 09:43:21 PDT 2007


"Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message 
news:fe8dbp$v10$1 at digitalmars.com...
> That's because you're trying to assign a constant type into a mutable
> type.  Which is what the compiler is telling you.  Either use 'auto' for
> the storage class, or explicit assign it to a 'string' (or const(char)[]
> if you really feel like it).

thanks, auto did it - and I think I like auto from now on.

> Well, line 11 was "writefln(cTest);", so I assume you've changed
> something, so I can't really help since I don't know what you've got any
> more.

here is the deal - 2.005
-----------------------------
import std.stdio;
import std.string;
import std.conv;

void main(char[][] args) {

 float fFloat = 214.4;
 float fBack = 0;
 float fTo = 0;

 auto cTest = std.string.toString(fFloat); // Works!
 writefln(cTest);

 fBack = toFloat(cTest); // Works too!
 writefln(fBack);

 fTo = to!(float)(cTest); // this does not work! to undefined

}
----------------------------- 




More information about the Digitalmars-d-learn mailing list