|
From: Ray K. <he...@er...> - 2003-09-16 06:27:09
|
> Date: Mon, 15 Sep 2003 21:49:17 -0300
> From: "jmarcelo.alencar" <jma...@bo...>
> To: "devcpp" <dev...@li...>
> Subject: [Dev-C++] Getch() and clrscr()
>
> i have use devcpp for a week and i've noticed that unlike Turbo C++ ,
> the functions getch() and clrscr() are not described in conio.h. I really
> like to work with them and i wonder if anyone could help me with this .
getch() and clrscr() aren't ANSI defined functions, so not every compiler
will have them. If you want to clear the screen,
use system("cls"); , included in #stdlib.h This calls the DOS function
that clears the screen. It's not portable, but neither is
clrscr(), and it's easy enough to change it, assuming the system you're
porting to has a built in clearscreen function. (In *nix, it's
system("clear"), for example.)
getch() may or may not have a working equivilant, depending on what you use
it for. If you just need to pause the screen, you can either use
system("pause"); (in which case the 'Press any key to continue.' message
will automatically be displayed), or getchar();, which is portable, but
requires you to hit enter to continue (not any key).
If you need getch() to actually record keypresses, you'll need to install
either the conio.h from TC++ or ncurses.h (I think that has a getkey
function, and possibly a clrscr() one too, but I'm not sure. If it does,
you should use that one, since it's more portable.)
|