Circle Calculator Help
    Steven Schveighoffer 
    schveiguy at yahoo.com
       
    Tue Jun 26 13:55:44 PDT 2012
    
    
  
On Tue, 26 Jun 2012 16:39:07 -0400, Alexander  
<alexander at alexandermohn.com> 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 at 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
    
    
More information about the Digitalmars-d-learn
mailing list