On 12/08/10 08:53, Stewart Gordon wrote: > On 08/12/2010 11:06, Nrgyzer wrote: >> Hey guys, >> >> I'm writing a console based tool for windows. To receive the users >> input, I >> try to use getch() but the compiler always says "Error: undefined >> identifier >> getch". When I use getchar() it compiles successfully, but getchar() >> doesn't >> returns after a single input. > > Under DMD 1, getch is declared in std.c.stdio. So import that. > > Under DMD 2, I don't know why it isn't there. But you just need to add > this declaration: > > extern (C) int getch(); > >> Is there any equivalent version in D for getch? > > D doesn't have its own API for console operations besides > stdin/stdout/stderr stuff. I guess it wasn't worth creating one partly > because it would be a load of pointless wrappers around C functions, and > partly because in these days where everyone uses GUI-based software > they're not used as much. > > Stewart.
Might it be useful to provide something a la conio.h? It doesn't have to be part of the standard, really (conio isn't a C standard, as I recall). I do a bit of console oriented work myself, as I mostly write tools, back-end programs, etc. Yes, it'd be mostly C wrappers, but it's never stopped us before. -- Chris N-S