111

Lisa via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 21 07:26:57 PST 2016


On Sunday, 21 February 2016 at 14:03:56 UTC, Ivan Kazmenko wrote:
> On Sunday, 21 February 2016 at 12:35:31 UTC, Lisa wrote:
>> ...
>> Is there smth wrong again?
>
> Yes.
>
> As a programmer, most of the time, you will have to try your 
> programs by yourself before you consider them correct.
>
> Now, run a compiler, and it complains:
> -----
> main.d(20): Error: cannot return non-void from void function
> -----
>
> Line 20 of your program is "return 0;", and the void function 
> in question is "void main() {...}".  So, you have to fix either 
> of that: make main return int instead of void, or remove the 
> return line.
>
> After that, the program will finally compile.  But that's not 
> the end, you have to try running it.
> "Enter side A:"
> shall we say,
> "1"
> and then it writes
> "Enter side B:"
> and fails:
> -----
> std.conv.ConvException at c:\Tools\dmd\windows\bin\..\..\src\phobos\std\conv.d(2729): no digits seen
> ----------------
> 0x0040666A in ...
> -----
>
> That's a whole lot of unfriendly error text on the screen, but 
> the human-readable part is "no digits seen" when reading 
> variable B.
>
> Now, read the chapter of Ali's book again very carefully, or 
> one of the posts here.  You may then notice that the space 
> inside the quotes is important, and also learn why.
>
> The bottom line: the task of writing a program is not finished 
> until you can compile it, run it, give it at least a few 
> example inputs, and it prints the right output for all these 
> inputs.
>
> Ivan Kazmenko.

Thank you sooooo much! :)
Thanks everyone!) You're really cool)



More information about the Digitalmars-d-learn mailing list