- How do you clear the console screen in C?
- 13 Answers 13
- How to Clear Command Prompt
- How to Clear Command Prompt in Windows
- How to Clear a Windows Command or CMD Screen
- How to Clear Command Prompt History on Windows
- How to Clear Command Prompt in Linux
- How to Clear a Linux Command or Shell Screen
- How to Clear a Linux Shell Command History
- How to clear mysql screen console in windows?
- 24 Answers 24
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.
How to Clear Command Prompt
This Itechguide teaches you how to clear command prompt in Windows and Linux. The guide also covers steps to clear command prompt history in Linux and Windows.
Expand “Browse Post Topics” below to go straight to a topic.
Browse Post Topics
How to Clear Command Prompt in Windows
This section is divided into 2 sub-sections. The first teaches you how to clear a Windows CMD command or screen. The second covers steps to clear Windows Command Prompt command history – delete all previous commands in the current section.
How to Clear a Windows Command or CMD Screen
- If you enter a command you do not intend to in a Command Prompt, to clear the command from the CMD screen, press the Esc key on your keyboard.
In this example, I entered the command cd \, to clear it from command prompt, I will press the Esc key on my keyboard – see the location of Esc key in the second image below (last key on the top left).
The screen now clear of the command!
- However, if you have been running a lot of commands on the current CMD section and want to clear everything off the screen, type cls and press enter.
The cls command clears everything from the Command Prompt screen and gives you a clean screen.
How to Clear Command Prompt History on Windows
As you run commands in CMD, the shell keeps a history of all the commands you have executed in the current section. This makes it easy to call previous commands – using the up arrow key.
To clear command prompt commands from the current section, press Alt and F7 keys on your keyboard simultaneously. Before you press Alt+F7, ensure that Cmd is open and that you clicked your mouse on it.
How to Clear Command Prompt in Linux
This section teaches you how to clear a command you typed but do not intend to execute. You also learn how to clear the entire Linux command shell of everything on the screen – including previous commands and command results. The section also covers steps to clear Linux command shell history.
How to Clear a Linux Command or Shell Screen
- If you enter a command you do not intend to in a Linux shell, to clear the command from the shell’s screen, press the Backspace key several times until the command is cleared from the screen.
In this example, I entered the command vi, to clear it, I will press Backspace key on my keyboard several times – see the location of Backspace key in the second image below (second row, top left – beneath the Delete key).
- However, if you have been running a lot of commands on the current Linux shell and want to clear everything off the screen, type clear and press enter.
Everything on the shell’s screen is gone!
How to Clear a Linux Shell Command History
As you run commands in Linux shell, the shell keeps a history of all the commands you have executed in the current section. This makes it easy to call previous commands – using the up arrow key.
However, to clear all previous commands from the current section, enter history -c and press enter
This will clear all previous commands from the current shell section.
You can use the methods described in this Itechguide to clear command prompt in both Linux and Windows! I hope you found this Itechguide helpful. If you found it helpful, kindly vote Yes to the “Was this post Helpful” question below.
Alternatively, you could ask a question, leave a comment or provide feedback with the “Leave a Reply” form found towards the end of this page.
Finally, for more Windows 10 Itechguides, visit our Windows 10 How-To page.
How to clear mysql screen console in windows?
The title is my question. I googled and try something like
but none of them works. anyone show me how to clear screen, just like cls command in window
24 Answers 24
This is not possible on Windows.
EDIT:
I don’t think Any of the commands will work. In linux Ctrl-L will do the job. in windows there is no equivalent. You can only Exit MySql, Type CLS and then re-enter MySql.
Just scroll down with your mouse
In Linux Ctrl + L will do but if your scroll up you will see the old commands
So I would suggest scrolling down in windows using mouse
On linux : you can use ctrl + L or type command system clear .
You are typing the command wrong. It is «\» before «!» and not after. The command ctrl+L will not work for windows. To clear mysql console screen, type following command.
This will do the job for windows. «\!» is used to execute system shell command. «cls» is command to clear windows command prompt screen. Similarly if you are on linux, you will type «ctrl+L» or following,
although there is bug for clearing the screen in MySQL, I have found one tactic trick whatever you want to say.
you can easily clear the screen using this.
just press ( ctrl + down arrow ) until you reach to top. happy codding.
I had the same issue, and CTRL + L worked for me on Windows 10.
mysql console can cleared out on windows by using shortcut key
This is what I did to get around this bug. The windows console (cmd) is just not worth using for anything other than some simple commands. So the following is what I did.
Installed Cygwin (Go here) It is pretty straight forward to install. You can watch this video. It explains very easily how to install cygwin. Make sure when you select the packages that you want to install includes Mintt (it is basically a better shell or cmd) and mysql client package.
Once you are done installing it, you should add the bin folder from cygwin in your PATH Environmental Variables(The above video explains that as well)
Now You will have an icon on the desktop for cygwin. Open it up and login to mysql using the normal commands. You will need to put the ip of the mysql server in the command to make it work. I use the following logging in MySQL which was installed through wamp
You can add more arguments in there if you want. Once you get in mysql just press ctrl + L and you will clear the screen.