cmd如何运行c程序_如何在CMD中运行C和C ++程序

《cmd如何运行c程序_如何在CMD中运行C和C ++程序》

cmd如何运行c程序

In this article I will tell you how to run C and C++ program in CMD.

在本文中,我将告诉您如何在CMD中运行C和C ++程序。

CMD or Command Prompt is a command line interpreter in Windows operating system. Running C and C++ programs using command prompt is useful in case you don’t have an IDE installed in your system.

CMD或命令提示符是Windows操作系统中的命令行解释器。 如果您的系统中未安装IDE,则使用命令提示符运行C和C ++程序非常有用。

Also Read: Configure Notepad++ to Run C, C++ and Java Programs

另请阅读: 配置Notepad ++以运行C,C ++和Java程序

Things you will need

您需要的东西

You must have a C or C++ compiler like GCC, Visual C++, etc. already installed in your system. If you don’t have any, you can easily get them by searching on Google.

您必须已经在系统中安装了C或C ++编译器,例如GCC,Visual C ++等。 如果您没有,可以通过在Google上搜索轻松获得它们。

如何在CMD中运行C和C ++程序 (How to Run C and C++ Program in CMD)

1.Before running programs we must set the path of compiler. So, first right click on Computer icon and go to Properties option.

1.运行程序之前,必须设置编译器的路径。 因此,首先右键单击“ 计算机”图标,然后转到“ 属性”选项。

《cmd如何运行c程序_如何在CMD中运行C和C ++程序》

2. Click on Advance system settings and then Environment Variables.

2.单击高级系统设置 ,然后单击环境变量

《cmd如何运行c程序_如何在CMD中运行C和C ++程序》

3. A new window will open, there click on New button. In Variable name filed enter path and in Variable value filed enter the path of the bin folder of compiler.

3.将打开一个新窗口,然后单击“ 新建”按钮。 在变量名字段中输入路径 ,在变量值字段中输入编译器的bin文件夹的路径。

《cmd如何运行c程序_如何在CMD中运行C和C ++程序》

4. You can find the path of bin folder by going to the directory where you have installed the compiler.

4.您可以转到安装编译器的目录来找到bin文件夹的路径。

5. After that click all OK buttons to save the information.

5.之后,单击所有确定按钮以保存信息。

6. Press Win+R keys to open Run. Type cmd and press enter to open command prompt.

6.按Win + R键打开“运行” 。 键入cmd ,然后按Enter键打开命令提示符。

7. Now change the directory to where you have saved your C or C++ program file. Lets say you have saved the program on Desktop then type cd desktop and press enter.

7.现在,将目录更改为保存C或C ++程序文件的目录。 假设您已将程序保存在桌面上,然后键入cd桌面并按Enter。

8. Now for compiling the program type gcc filename. Here filename is the name of the program file. I have used gcc command because I have installed GCC compiler in my system. The command will change if you are using any other compiler, like for Turbo C++ it will be tcc, for Borland C++ it will be bcc and so on.

8.现在要编译程序,请输入gcc filename 。 filename是程序文件的名称。 我使用gcc命令是因为我已经在系统中安装了GCC编译器。 如果使用任何其他编译器,该命令将更改,例如对于Turbo C ++ ,它将是tcc,对于Borland C ++ ,它将是bcc,依此类推。

9. For running the program just type the name of the source file without .c or .cpp extension and press enter.

9.要运行该程序,只需键入不带.c.cpp扩展名的源文件的名称,然后按Enter。

10. If you have followed steps properly then you can see the output.

10.如果正确遵循了步骤,则可以看到输出。

《cmd如何运行c程序_如何在CMD中运行C和C ++程序》

Comment below if you have any doubts regarding above how to run C and C++ program in CMD article.

如果您对以上如何在CMD中运行C和C ++程序有任何疑问,请在下面评论。

Happy Coding!!

快乐编码!

翻译自: https://www.thecrazyprogrammer.com/2015/09/how-to-run-c-and-cpp-program-in-cmd.html

cmd如何运行c程序

    原文作者:culing2941
    原文地址: https://blog.csdn.net/culing2941/article/details/108618737
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞