3

While programming C on the old Turbo C++ compiler I can use the clrscr() method of the "conio.h" header file but not on Dev C++ 5.4.2.(It gives an unusual error Id returned 1 exit status. Although it has nothing to do with the clrscr() and When I removed the clrscr() statement it works perfectly fine! ) So, has the method clrscr() method got deprecated. What is the meaning of the error ?

enter image description here One more question is "are compiler and library of a language associated". So for a particular compiler a corresponding library is like binded to it.

Zaid Khan
  • 786
  • 2
  • 11
  • 24
  • 2
    You can `printf("hi");` perfectly well without clearing the screen first. It's better to focus on real programming issues rather than worrying about annoyances like this. If you're writing a program with an actual text interface then use a proper terminal handling library, otherwise let users clear their screen when *they* want to. – Crowman Sep 12 '13 at 13:58
  • How do you get from "undefined reference to 'clrscr'" to "... it has nothing to do with the clrscr()"? It would seem that it pretty obviously *does* have something to do with the clrscr() call... – twalberg Sep 02 '15 at 20:37

6 Answers6

6

clrscr() didn't get deprecated because it was never part of any standard. It was a vendor-specific function provided as an extension by Borland in the (also non-standard) <conio.h> header. Modern compilers no longer provide this function.

There's a couple of ways to emulate it, and I'm sure you can find it here - just look at the links in the Related section on the right side.

Sebastian Redl
  • 69,373
  • 8
  • 123
  • 157
6

please include stdlib.h file and then call system("cls") and enjoy.

#include<stdlib.h>

system("cls");
ritesh anand
  • 61
  • 1
  • 2
2

you can use system("cls"); instead of clrscr();

Paulo
  • 1,458
  • 2
  • 12
  • 26
1

The Conio.h header is not a part of C Standard Libary. According to wikipedia:

conio.h is a C header file used mostly by MS-DOS compilers to provide console input/output.1 It is not described in The C Programming Language book, and it is not part of the C standard library, ISO C nor is it defined by POSIX.

So you just don't have this header.

The errors you are getting are linker errors reporting that it can't find the clrscr() function in any of the headers that hare available for it.

Also, check this question.

Community
  • 1
  • 1
SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
  • 3
    Clarification - the linker error is because `clrscr()` can't be found in any of the libraries being linked in, not because of missing `conio.h` (that would be flagged by the compiler stage). It's entirely possible to have the header file present but not the library, and vice versa. Or maybe the right library is simply not being included in the link command... – twalberg Sep 12 '13 at 13:59
  • @twalberg, fair enough. – SingerOfTheFall Sep 13 '13 at 05:10
1

system("cls"); works fine instead of clrscr();

Natan Streppel
  • 5,759
  • 6
  • 35
  • 43
Amol J
  • 111
  • 2
  • 12
1

clrscr() will not work untill you download & link conio.o in your project. Download conio.h , conio.o & then copy paste conio.h in include folder & conio.o in lib folder. Link conio.o in your project (Project->Project option->Parameters->Add Library or Object) .. Then run it.

AbcAeffchen
  • 14,400
  • 15
  • 47
  • 66
udit043
  • 1,610
  • 3
  • 22
  • 40