'clrscr()' and 'conio.h' not working

11.2k views Asked by At

First of all.... I can't include 'conio' in my file (nor 'conio.h') and then I can't use 'clrscr()' in my program...

The code is like this

#include<iostream>
#include<conio>         \\even 'conio.h' isn't working

main()
{
    clrscr();
}

It shows an error like this...

/home/myni/Documents/Codes/CPP/Anjuta/src/main.cc:2:16: fatal error: conio: No such file or directory

And when I remove the 'conio' header file, it shows something like this...

/home/myni/Documents/Codes/CPP/Anjuta/src/main.cc:5:9: error: ‘clrscr’ was not declared in this scope
2

There are 2 answers

0
Marcus Müller On

From Wikipedia:

conio.h is a C header file used mostly by MS-DOS compilers to provide console input/output.[1] It is not part of the C standard library or ISO C, nor is it defined by POSIX.

In short: Your program is not portable to Unix (or in fact, anything but MSDOS or Win32).

So unless you're using an environment that has this (Microsoft compiler), you'll need to find something else to do console manipulation. I recommend ncurses if you need low-level functions to deal with the console.

0
itsols On

Looks like you're trying to run the program on Linux. I did this with Ubuntu some time ago and I think this should work for you.

system("clear");

This is how I cleared the screen. I hope this helps.