On Tue, 26 Jun 2012 16:39:07 -0400, Alexander
<[email protected]> wrote:
So, I've taken out the loop part that is "interesting" and replaced it
with the readln() alternative.
However, I'm still getting what looks like an error.
I managed to take a screenshot of what pops up, and here is what it says:
std.conv.ConvException@C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(1597):
Unexpected '
' when converting from type char[] to type float
-----------------
C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(1597): float
std.conv.toImpl!(float, char[]).toImpl(char[])
C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(245): float
std.conv.to!(float).to!(char[]).to(char[])
C:\Users\Alexander\Documents\D\circlecalc.d(23): float
circlecalc.askradius()
C:\Users\Alexander\Documents\D\circlecalc.d(80): _Dmain
-----------------
Does anyone understand this error code?
Oh, readln includes the newline by default, so to!float is choking on that.
Just remove the newline character:
radius = to!float(strip(number));
(must import std.string)
-Steve