How to Hide and Show a Console Window in C++? Last Updated : 27 Nov, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The task is to hide and Show the console window of a C++ program. The program for the same is given below. Note: The results of the following program can only be seen when it is executed on a console. Example: C++ // C++ program to hide and show a console window #include <iostream> #include <windows.h> using namespace std; void countdown() { cout << "3" << endl; Sleep(1000); cout << "2" << endl; Sleep(1000); cout << "1" << endl; Sleep(1000); cout << "0" << endl; } int main() { countdown(); HWND window; AllocConsole(); // You Can Find HANDLE of other windows too window = FindWindowA("ConsoleWindowClass", NULL); ShowWindow(window, 0); countdown(); ShowWindow(window, 1); } Output: Explanation: The above program counts from 3 to 1 before the Console Window disappears. After the window has disappeared, the ShowWindow helps the program so that the Console Window reappears again after counting from 3 to 1(executing the countdown function). The execution of the program can be understood by understanding the key functions of the program. #include<windows.h> – The windows.h header in C++ programming languages are specifically designed for windows and contain a very large number of windows specific functions.AllocConsole()- AllocConsole initializes standard input, standard output, and standard error handles for the new console. ShowWindow()- Sets the specified window's show state.FindWindowA()- Takes string parameters and checks whose class name and window name match the specified strings Comment More infoAdvertise with us Next Article How to Hide a Console Window On Startup in C++? P pritamauddy25 Follow Improve Article Tags : Technical Scripter C++ Programs C++ Technical Scripter 2022 C++ Misc Programs +1 More Practice Tags : CPP Similar Reads How to Hide a Console Window On Startup in C++? The console is an OS window through which users interact with the operating system either by entering text input through the computer keyboard or by reading text output from the computer terminal. The term console is derived from the French word 'consolide', which is derived from the Latin word 'con 3 min read How to Open and Close a File in C++? In C++, we can open a file to perform read and write operations and close it when we are done. This is done with the help of fstream objects that create a stream to the file for input and output. In this article, we will learn how to open and close a file in C++. Open and Close a File in C++ The fst 2 min read How to Change Console Color in C++? In C++, most of the inbuilt input and output functions take input and show output from/to the console window. This can be useful for highlighting important information, creating visually appealing interfaces, or simply adding a touch of personalization to our console applications. How to Change Cons 3 min read How to Redirect cin and cout to Files in C++? In C++, we often ask for user input and read that input using the cin command and for displaying output on the screen we use the cout command. But we can also redirect the input and output of the cin and cout to the file stream of our choice. In this article, we will look at how to redirect the cin 2 min read How to Detect Keypress in Windows Using C++? In Windows programming, detecting keypress events is a fundamental requirement for many applications like games, user interfaces, and many more. In this article, we will learn how to detect keypress events in Windows using C++. Example Input: Press any key Output: Pressed Key: G (ASCII value: 71) Pr 3 min read How to Compile a C++ Program Using GCC In C++, the GNU Compiler Collection (GCC) is one of the most popular C/C++ compiler that is used to compile and execute the C and C++ program. In this article, we will learn how to compile a C++ program using GCC. Compiling a C++ Program Using GCC The GNU Compiler Collection (GCC) is a versatile too 2 min read Like