C & C++ getch() and clrscr() functions in Linux

Status
Not open for further replies.
Hope this helps newbies.

clrscr()
Code:
system("clear");      //Needs cstdlib headder file so do #include<cstdlib>
getch()
Code:
getchar();            // Needs stdio.h so do #include<stdio.h>
And yeah, always use
Code:
using namespace std;
after including headders. Need that because actual usage of cout otherwise is std::cout and not cout, and so on.
 

Liverpool_fan

Sami Hyypiä, LFC legend
system("clear") is NOT exactly same as clrscr() and gives a warning when I try it.
abc.c:7: warning: implicit declaration of function ‘system’
abc.c:8: warning: control reaches end of non-void function


(you can avoid the first warning by stdlib.h but the second one stays)

Also I think, Linux users don't need a clrscr() 'coz:
(1) It will not go according to usual conventions used. For instance there are no terminal programs I have used which actually clear the space.
(2) Newbies or even amateurs who generally want to program in Linux should use Geany. It's excellent.
 
^Fully agree, though I don't get the errors.

1. Yup. We guys don't like it when a program abruptly clears the valuble output.

2. WTH ? Geany ? How does the IDE have any thing to do with a function ?


Anyway, I posted this because newbies and switches from windows may need something to make their windows apps compatible with linux.
 
Status
Not open for further replies.
Top Bottom