On Tue, 26 Jun 2012 10:40:18 -0400, Alexander
<alexan...@alexandermohn.com> wrote:
Hello everybody!
I am new to D, and I am working on a program that calculates the area
and circumference of a circle. However, when I compile it and run it, it
waits for the user to input the radius, but then it closes while
displaying a bunch of stuff.
I'm assuming you are running on Windows. Windows with console output will
allocate a console, and destroy the console after the program is finished.
If you want it to keep the console up, start the command line interpreter
(cmd.exe) before-hand and then run the program from within the console.
Then all the output stays put.
//Wait
void wait()
{
writefln ("Type A to continue!");
exittest();
}
//Exit tester
void exittest()
{
char[] a;
stdin.readln(a);
if (a == "A")
{
exit();
}
else
{
wait();
}
}
Hm... interesting code here :)
This is not horrible, just... weird.
You probably want to avoid recursion in this case:
void wait()
{
char[] a;
while(a != "A")
{
writeln("Type A to continue!");
stdin.readln(a);
}
}
-Steve