Read integer from console and sleep
bearophile
bearophileHUGS at lycos.com
Fri May 4 10:42:40 PDT 2012
Ali Çehreli:
> import std.stdio;
> import core.thread;
>
> void main()
> {
> write("Enter a time to sleep (in seconds): ");
>
> long time;
> readf(" %s", &time);
>
> writeln("Sleeping...");
> Thread.sleep( dur!("seconds")(time) );
> writeln("Awake!");
> }
If you want Iain I'll put this version by Ali Çehreli in
Rosettacode:
import std.stdio, core.thread;
void main() {
write("Enter a time to sleep (in seconds): ");
long secs;
readf(" %d", &secs);
writeln("Sleeping...");
Thread.sleep(dur!"seconds"(secs));
writeln("Awake!");
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list