> # include<stdio.h>
> # include<conio.h>
>
>   void main()
> {
> clrscr();
> printf("First program using GCC");
> getch();
> }
>

The following is what u need on Linux,

#include <stdio.h>
#include <curses.h>

void main()
{
     initscr();                         // initialize curses screen
     printw("First program using GCC"); // note the printw
     getch();                           // get single character
     endwin();                          // end screen
}

To compile include -lcurses. And, If you need more terminal 
functionality like creating boxes, adding colors etc., try to find a 
curses tutorial on the web, it will be helpful.

If you don't want/like curses, then the following code will do the job 
but this is a bit advanced,

#include <string.h>
#include <unistd.h>
#include <termios.h>
#include <sys/ioctl.h>

int main(void)
{
     char* ptr = "First program using GCC";
     char  ch;

     struct termios cTerm;

     write(1, "\033[H\033[J", 6);     // Goto Home + Erase to Bottom

     ioctl(0, TCGETS, &cTerm);        // Get Terminal Structure
     cTerm.c_lflag &= ~(ICANON|ECHO); // read char by char + no echo
     ioctl(0, TCSETS, &cTerm);        // Set Terminal Structure

     write(1, ptr, strlen(ptr));      // Unbuffered write to stdout
     read(0, &ch, 1);                 // Unbuffered read from stdin

     cTerm.c_lflag |= (ICANON|ECHO);  // Reset canonical mode + echo
     ioctl(0, TCSETS, &cTerm);        // Set Terminal

     return 0;
}

-- 
0
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to