-2
#include<stdio.h>
#include<conio.h>

void main()

{
     int i;
     clrscr();
     printf("Enter the number to be displayed");
     scanf("%d",&i);
     printf("The entered number is %d",i);
     getch();
     }

I am able to run the above program in Turbo C++ but in Dev C++ I'm getting this error.

error: enter image description here

iraj jelodari
  • 3,118
  • 3
  • 35
  • 45
Mayank
  • 11
  • 5
  • (almost certainly) unrelated to your issue at hand, but also take a look at: https://stackoverflow.com/questions/204476/what-should-main-return-in-c-and-c – kopecs Dec 30 '19 at 03:45
  • Turbo C++ is not a C++ compiler as it predate the first C++ standard (C++98) for almost a decade, therefore don't expect valid C++ code to be compiled in Turbo C++ and vice versa – phuclv Dec 30 '19 at 03:49
  • @mayank you should write the error in the post, don't upload error or code's images. – iraj jelodari Dec 30 '19 at 03:49
  • But I'm getting this error in Dev C++....not in Turbo C++. – Mayank Dec 30 '19 at 03:50
  • [clrscr()not working in VC++(VS 2008)…?](https://stackoverflow.com/q/3646038/995714), [Why do I got error in clrscr(); it says undefined?](https://stackoverflow.com/q/41137638/995714), [Error with clrscr() on Dev C++ 5.4.2](https://stackoverflow.com/q/18766159/995714) – phuclv Dec 30 '19 at 03:51
  • 1
    @MayankSingh dev C++ is an IDE, not a compiler. But it's likely using a standard C++ compiler (gcc) so it can't compile non-compliant Turbo C++ code like yours – phuclv Dec 30 '19 at 03:52
  • @phuclv So what do i do to remove this error and get output like turbo c++. – Mayank Dec 30 '19 at 03:55
  • Does this answer your question? [Error with clrscr() on Dev C++ 5.4.2](https://stackoverflow.com/questions/18766159/error-with-clrscr-on-dev-c-5-4-2) – Kalpesh Kundanani Dec 30 '19 at 04:10
  • You may get your answer here: https://stackoverflow.com/questions/18766159/error-with-clrscr-on-dev-c-5-4-2 – Kalpesh Kundanani Dec 30 '19 at 04:10

1 Answers1

0

<conio.h> is a non-standard header provided by Borland and a handful of other compilers and libc implementations. Dev C++ typically uses one of the Windows GCC ports, which don't provide any implementation of those functions.

If you want to use some sort of clrscr function in both you're going to have to come up with a more portable solution, because <conio.h> will not work with GCC.

nickelpro
  • 2,537
  • 1
  • 19
  • 25