How to run a C++ file in Command Prompt or CMD
In this tutorial, We are going to learn about how to run a C++ file in Command Prompt or CMD. So let’s know a little what is CMD.
Running C ++ programs using the command prompt is useful if you do not have an IDE installed on your computer. It uses simple steps to run C++ programs.
Steps to launch the C ++ program in CMD
- Right-click and navigate to the Computer icon and then to the Properties option.
2. Then go to system settings and go to variable environment.
3. A new window will appear and then click a new button. In the variable word field, you need to enter the path and folder of a different value bin.
4.You will find the path to the bin folder by clicking directly on the directory where you are having your compiler.
5. After all the above steps click on OK button to save all the information.
6. Then press the key Win+R to open Run. There you need to type cmd and then press enter key to open the cmd prompt. Now you have to change the directory where you have saved the required C++ program files.
8. You can start compiling the program type gcc filename. Click the enter button without .cpp or.c extension in order to run the program.
9. Output will be seen on the screen.