Clear Screen Command In Dev C++
Aug 26, 2017 Please refrain from using clrscr. This is a non-standard function which ships with conio.h which is a part of TURBO C. Dev c++ handbook. If you really need to clear your screen, try: code#include #define CLRSCR system(“clear”); inline void foo C. Aug 04, 2008 If you are writting your program to run in console, then it simply uses the command available to you on your CMD console. And there are a lot of them, but like Duoas, and PersonJerry pointed out, that is highly bad practice. I use clrscr; to clear the screen but anyone knows how to clear the screen in any particular area. If you need that kind of control you should be using a console graphics library, or better yet, a full graphical application rather than the console. Aug 21, 2002 How do I clear screen in a C program? And we all know what 'undefined' means: it means it works during development, it works during testing, and it blows up in your most important customers' faces.' Bangalore, India Posts 345 system(clear) If clear is not a declared variable holding the shell command to clear the screen, then. Some non-Microsoft versions of C provide a clrscr function for clearing the screen in a DOS application. However, there is no Win32 Application Programming Interface (API) or C-Runtime function that will perform this function. To accomplish this task for a Win32 console application, use one of the following methods: Use a system function. Jan 10, 2007 On Windows, you can clear the screen by using the 'cls' command; there is no 'clear' command on Windows. I was able to use the following code to clear the screen (command window) using Borland C 5.5.1 for Win32 on Windows XP.
-->Definition
Clears the console buffer and corresponding console window of display information.
How To Use Clear Screen Command In Dev C++
Exceptions
An I/O error occurred.
Clear Screen In C
Examples
The following example uses the Clear method to clear the console before it executes a loop, prompts the user to select a foreground and background color and to enter a string to display. If the user chooses not to exit the program, the console's original foreground and background colors are restored and the Clear method is called again before re-executing the loop.
The example relies on a GetKeyPress
method to validate the user's selection of a foreground and background color.
This example demonstrates the CursorLeft and CursorTop properties, and the SetCursorPosition and Clear methods. The example positions the cursor, which determines where the next write will occur, to draw a 5 character by 5 character rectangle using a combination of '+', ' ', and '-' strings. Note that the rectangle could be drawn with fewer steps using a combination of other strings.
Remarks
Using the Clear method is equivalent invoking the MS-DOS cls
command in the command prompt window. When the Clear method is called, the cursor automatically scrolls to the top-left corner of the window and the contents of the screen buffer are set to blanks using the current foreground background colors.
Note
Attempting to call the Clear method when a console application's output is redirected to a file throws a IOException. To prevent this, always wrap a call to the Clear method in a try
…catch
block.