- Очистка экрана Clearing the Screen
- Пример 1 Example 1
- Пример 2 Example 2
- Пример 3 Example 3
- [SOLVED] How to Clear Command Prompt Screen Windows 10 [MiniTool News]
- Summary :
- Clear Command Prompt Screen with CLS Command
- Close Command Prompt and Open It Again to Clear Screen
- Clear Command Prompt Screen with Keyboard Shortcut?
- How to View Command Prompt Command History
- How to Save Command Prompt History
- What You Can Do with Command Prompt
- Organize Your Hard Drive Partitions
- Check and Repair Disk Errors
- Detect and Repair Corrupt System Files
- Verdict
- ABOUT THE AUTHOR
- How do you clear the console screen in C?
- 13 Answers 13
- Clear Screen
- ‘Clear’ command in the ConEmu menu
- Injurious operation
- Reason 1
- Reason 2
- Reason 3
- Reason 4
- Reason 5
- Resume
- Как очистить командную строку
Очистка экрана Clearing the Screen
Существует четыре способа очистки экрана в консольном приложении. There are four ways to clear the screen in a console application.
Пример 1 Example 1
Это рекомендуемый метод с использованием виртуальных последовательностей терминалов для всех новых разработок. This is the recommended method using virtual terminal sequences for all new development. Дополнительные сведения см. в обсуждении классических API консоли и виртуальных последовательностей терминалов . For more information, see the discussion of classic console APIs versus virtual terminal sequences .
Первый способ — настроить приложение для виртуальных выходных последовательностей терминала, а затем вызвать команду «очистить экран». The first method is to set your application up for virtual terminal output sequences and then call the «clear screen» command.
Дополнительные варианты этой команды см. в документации по виртуальным последовательностям, посвященной стиранию экрана . You can find additional variations on this command in the virtual terminal sequences documentation on Erase In Display .
Пример 2 Example 2
Второй метод — написать функцию для прокрутки содержимого экрана или буфера и задать заливку для видимого пространства. The second method is to write a function to scroll the contents of the screen or buffer and set a fill for the revealed space.
Это соответствует поведению командной строки cmd.exe . This matches the behavior of the command prompt cmd.exe .
Пример 3 Example 3
Третий метод заключается в написании функции для программного очистки экрана с помощью функций филлконсолеаутпутчарактер и филлконсолеаутпутаттрибуте . The third method is to write a function to programmatically clear the screen using the FillConsoleOutputCharacter and FillConsoleOutputAttribute functions.
Этот прием показан в следующем образце кода. The following sample code demonstrates this technique.
[SOLVED] How to Clear Command Prompt Screen Windows 10 [MiniTool News]
By Alisa | Follow | Last Updated December 16, 2019
Summary :
This post provides quick ways to clear Command Prompt (cmd.exe) screen in Windows 10. For troubleshooting Windows problems, MiniTool software also provides some free tools like free data recovery software, hard drive partition manager, PC backup software, etc.
Windows Command Prompt (cmd.exe) lets us quickly open applications, execute tasks, troubleshoot some Windows issues, etc. by typing command lines. After you type many command lines and finish the tasks, or type wrong command lines, how to clear Windows Command Prompt screen in Windows 10?
Check the easy ways below for how to clear CMD screen in Windows 10.
Clear Command Prompt Screen with CLS Command
After you open Command Prompt in Windows 10, and enter multiple command lines in the screen, you can type cls command line in Command Prompt window, and hit Enter button. This will clear the CMD screen in Windows 10. All typed previous commands in Command Prompt window will be cleared.
Close Command Prompt and Open It Again to Clear Screen
You can also close Command Prompt window and open again, it will also clear the Command Prompt screen in Windows 10.
Windows 10 repair, recovery, reboot, reinstall, restore solutions. Create Win 10 repair disk/recovery disk/USB drive/system image to repair Win 10 OS issues.
Clear Command Prompt Screen with Keyboard Shortcut?
If the Command Prompt window is cluttered and you want to clear the screen, you may wonder if there is a keyboard shortcut to easily clear it. Some online posts suggest using Alt + F7 keyboard shortcut to clear the command history. But I tried this way, it doesn’t work.
How to View Command Prompt Command History
After you type a series of command lines in Command Prompt window, you can type doskey /history command line, and hit Enter. This command will display all the commands you typed in the same sequence as you entered.
To view all command lines you entered in Command Prompt window after you access CMD, you can also press F7 key. This will pop up a window with a list of all previous typed command lines. You can use the Up and Down arrow key to select any command line in the list and press Enter to locate it.
Learn how to use the 10 best free Windows 10 backup and recovery tools to backup and restore Windows 10, and recover lost/deleted data from Windows 10 PC.
How to Save Command Prompt History
You can enter this command line doskey /HISTORY > filename.txt to save the commands history to a TXT, HTML, CSV, RTF file. You can enter a file name and a file extension. The file will be saved to the location where you execute this command.
What You Can Do with Command Prompt
You can use Windows Command Prompt to do many things. Below we introduces three common usages of Command Prompt. Press Windows + R, type cmd, and hit Enter to open Command Prompt.
Organize Your Hard Drive Partitions
You can run Windows Diskpart utility in Command Prompt to manage computer hard drive partitions.
You can type diskpart in Command Prompt window to open Windows Diskpart tool. Below is how to partition external hard drive with Diskpart.
- list disk
- select disk * (select the external hard disk)
- create partition primary size=* (specify a partition size in MB)
- assign letter=* (set a drive letter for the new partition)
- format fs=ntfs quick
- exit
Check and Repair Disk Errors
You can also type chkdsk *: /f /r command in Command Prompt, and hit Enter to use Windows CHKDSK to check and repair hard disk errors. Replace “*” with the target partition drive letter.
Detect and Repair Corrupt System Files
If your computer has problems, you can use Windows SFC tool to check and repair corrupted system files. You can type sfc /scannow command in Command Prompt, and hit Enter to use SFC tool to find and repair corrupted/missing system files.
Verdict
In conclusion, the easiest way to clear Command Prompt screen is to use CLS command or restart Command Prompt application.
How to fix my phone SD free? This post offers 5 ways for repairing corrupted SD card on (Android) phones, and help you easily restore SD card data and files in 3 simple steps.
ABOUT THE AUTHOR
Position: Columnist
Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.
How do you clear the console screen in C?
Is there a «proper» way to clear the console window in C, besides using system(«cls») ?
13 Answers 13
Well, C doesn’t understand the concept of screen. So any code would fail to be portable. Maybe take a look at conio.h or curses, according to your needs?
Portability is an issue, no matter what library is used.
This function will work on ANSI terminals, demands POSIX. I assume there is a version that might also work on window’s console, since it also supports ANSI escape sequences.
There are some other alternatives, some of which don’t move the cursor to <1,1>.
For portability, try this:
Then simply call clrscr() . On Windows, it will use conio.h ‘s clrscr() , and on Linux, it will use ANSI escape codes.
If you really want to do it «properly», you can eliminate the middlemen ( conio , printf , etc.) and do it with just the low-level system tools (prepare for a massive code-dump):
A workaround tested on Windows(cmd.exe), Linux(Bash and zsh) and OS X(zsh):
Using macros you can check if you’re on Windows, Linux, Mac or Unix, and call the respective function depending on the current platform. Something as follows:
Since you mention cls , it sounds like you are referring to windows. If so, then this KB item has the code that will do it. I just tried it, and it worked when I called it with the following code:
There is no C portable way to do this. Although various cursor manipulation libraries like curses are relatively portable. conio.h is portable between OS/2 DOS and Windows, but not to *nix variants.
The entire notion of a «console» is a concept outside of the scope of standard C.
If you are looking for a pure Win32 API solution, There is no single call in the Windows console API to do this. One way is to FillConsoleOutputCharacter of a sufficiently large number of characters. Or WriteConsoleOutput You can use GetConsoleScreenBufferInfo to find out how many characters will be enough.
You can also create an entirely new Console Screen Buffer and make the current one.
Clear Screen
When you need to clear your screen, just issue proper command in your shell. cmd, bash, PowerShell, or dozens of other console applications have either clear or cls . Moreover, many of them respond to Ctrl+L hotkey.
It doesn’t matter are you working in ConEmu or any other terminal, your shell behavior is the same.
‘Clear’ command in the ConEmu menu
There are requests from our users to add ‘Clear’ command to the ConEmu system menu.
These requests were rejects by a simple and logical reason — ConEmu (terminal) do not know what console application is doing. ConEmu able to show application output, but that is all.
However, since GuiMacro Write was implemented, anyone may create a macro to Write(«\ec») , which actually resets the terminal. So, anyone may choose desired hotkey for action ‘Reset terminal: clear screen, backscroll, move cursor to the upper-left corner’.
BTW, Write may be used to push to console several colored lines using ANSI sequences to ‘mark’ some point in real-time logs (tail -f). Example.
Injurious operation
Terminal reset may harm normal behavior of running console applications. So, use it carefully and on your own risk!
Reason 1
You are editing file in vim, manage your files with Far Manager, or do something else not related to simple ‘read-line-execute-command’, and call this mysterious ‘clear’ menu item. What would happen?
Your screen would be garbaged.
Console app is sure that cursor is located in certain position and all visible lines of text file were printed properly. But after such ‘external clear’ this would not be true.
Reason 2
Even with cmd or bash. They have printed PROMPT. But after ‘external clear’ there would be no PROMPT! The screen would be absolutely clean, but shell do not know that it must ‘reprint’ PROMPT. It just waits for user input!
Reason 3
One may say: users know when they want to clear screen in appropriate moment. Yep. But that would case garbaged output due to abovementioned reasons.
Reason 4
Not related to the terminals, but it may serve as obvious example.
Imagine, that Windows would have a hotkey to Clear The Monitor. What shall it do? Fill screen with black color. And how do you think running applications and Windows would look after that? Garbage, rubbish and more.
Reason 5
In the Issue 550 I been noted about ‘example’ of the feature implementation in the Tera Term.
Well, I have tried both local cygwin connection and remote ssh to Ubuntu in the Tera Term, and it just doesn’t work.
- Connect (to cygwin or remote via ssh)
- Execute ls
- Call menu item ‘Reset terminal’
- Get fail
- Cursor jumps to the <0,0>and that’s all!
- Screen is not cleared!
- Prompt is not re-printed!
Resume
To clear your screen do one of the following:
- Issue clear or cls in your shell.
- Press Ctrl+L or other hotkey, if your shell supports it. Even cmd+clink may do that.
- Restart your tab. Default hotkey is Win+
.
Как очистить командную строку
Используйте следующие команды для управления самим инструментом командной строки:
— cls — очистка командной строки;
— cmd — запуск копии командной строки;
— color — выбор цветового отображения фона и текста командной строки;
— prompt — редактирование текстового приглашения командной строки;
— title — выбор заголовка окна для текущего сеанса командной строки;
— exit — завершение работы инструмента командной строки.
Введите следующее значение в поле командной строки для получения информационных данных системы:
— driverquery — отобразить свойства и текущее состояние драйвера выбранного устройства;
— systeminfo — показать данные системы и конфигурации компьютера;
— ver — отобразить информацию о текущей версии операционной системы.
Измените необходимые параметры системы с помощью следующих команд:
— date — возможность редактирования текущей даты;
— schtasks — возможность создания расписания запуска программ или выполнения команд;
— shutdown — выключение комепьютера8
— taskkill — принудительное завершение работы выбранной программы или процесса;
— time — возможность редактирования данных системного времени.
Основными значениями команд командной строки принято именовать следующие:
— copy — копировать файл;
— del — удалить файл;
— find — найти текстовое значение в выбранном файле;