Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why clrscr() and getch() is treated as error in GDB compiler but this is not produce error in turbo c

0 votes
asked Jun 18, 2021 by avanish yadav (170 points)

1 Answer

+1 vote
answered Oct 31, 2021 by Peter Minarik (86,160 points)
edited Oct 31, 2021 by Peter Minarik

Both clrsc() and getch() are non-standard C functions defined in the Windows header conio.h.

getch() on it's own is also found in the Linux curses.h header.

Probably Turbo C includes these on it's own (making your code platform dependent).

OnlineGDB runs on a Linux server so your code will not run here (as your code only runs on Windows platform). You could include curses.h and remove the clrscr() call to make your code would compile. However, it would not run correctly (probably due to the way user input is sent from your browser to the server).

I'd suggest using the standard library functions, such as getchar(). This would make your code platform independent. I do not know a way of clearing the screen in a platform-independent way (unless you start using macros that would run specific code for Windows or Linux). You could consider, if you really-really need that clear screen at all.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...