[Ilugc] First Encounter with GCC

  • From: kiranmurari@xxxxxxxxx (Kiran Murari)
  • Date: Thu, 28 Jul 2011 12:19:01 +0530

1) How to clear the output screen (replacement of clrscr() ) in GCC ?


Use system() for clearing the screen. The replacement would be:
system ("clear");

2) Is there any similar  kind of replacement for getch() too ?




3) Why conio.h doesn't work in GCC ?


conio.h is specific to some DOS compilers. Same functionality can be
acheived using ncurse library. Ref:
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

Having said that, getch() is a function defined in ncurse library and you
should link the curses library when compiling your program.

After these modifications your program should look like:

****************************************
# include <stdio.h>

void main()
{
    system ("clear");
    printf("First program using GCC");
    getch();
}
****************************************

You compile the program with the following command:
gcc -lcurses -o hello hello.c--


--

Kiran

Other related posts: