search
HomeDevelopment ToolssublimeAn article explains how to configure the c compilation environment and test sublime text3

下面由sublime教程栏目给大家介绍sublime text3怎么配置c编译环境,希望对需要的朋友有所帮助!

  • 软件下载可以在官网下载,均为免费软件
  • sublime text3虽然收费但是支持无限期试用且功能不受限制(免费软件)

使用sublime text3编译c语言部分


准备工作

  • 下载sublime text3
  • 配置计算机c语言编译环境,下载MinGW即可
  • 配置MinGW的系统变量
    • 将下载解压的MinGW的bin文件路径写进系统的path路径下。 下面有教程!
  • 配置sublime text3c语言编译环境

配置环境变量

  • 为了方便,一般我们会把gcc所在的路径加入系统的环境变量,这样就可以直接使用gcc命令而不用绝对路径。右键计算机->属性->高级系统设置->环境变量

  • 在path的值中,可以发现有一些目录,他们之间用英文的分号分隔。我们双击path,把我们gcc的路径 C:\MinGW\bin 添加进去。 要注意前后的英文分号。

  • 确定以后 就可以在任意目录下直接使用gcc命令了。可以在任意目录打开cmd窗口,输入gcc - v查看环境变量是否设置成功。如果仍然提示不是内部或外部命令,说明环境变量设置失败。

  • 如果失败,请重新配置环境变量!这一步至关重要,新手很容易卡在这一步!

新建sublime text3的c语言编译环境

  1. 第一步,打开sublime text3 选择 中文版:工具>>编译系统>>新建编译系统 英文版:tool –> Build System –> New Build System
  1. 输入下面代码保存
{"shell_cmd":"g++
 \"${file}\" -o \"${file_path}/${file_base_name}\"","file_regex":"^(..[^:]*):([0-9]+):?([0-9]+)?:?
 (.*)$","working_dir":"${file_path}","selector":"source.c,
 source.c++", 


"variants":


[


{"name":"Run","shell_cmd":"g++
 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""}


]


}
  • 按Ctrl+s保存,会自动打开user目录(Sublime Text 3\Packages\User),我们修改 文件名为 c.sublime-build,保存在此目录。
    • 保存之后,可以在Tools -> Build System下看到刚才新建的c了(工具->编译系统)
      至此,已经配置完了所有环境,只需要写入代码即可运行,下来我们一起写一个简单的程序测试一下

  1. 首先写上一段c代码进sublime text3
#include<stdio.h>	\\经典的c语言入门程序int main(void)
{	
printf("hell\n");return 0;
}

2. 然后选择编译环境 选择工具>>编译系统>>选择c即可

3.写完代码按下快捷键:Ctrl+Shift+B

4.第一行中c就是对应执行配置文件中的第三行 gcc -Wall $file_name -o $file_base_name作用是编译。

第二行的c-Run对应后面的命令 gcc -Wall $file -o $file_base_name && start cmd /c \”${file_path}/${file_base_name} & pause\”,作用是是在新的cmd窗口运行。这样就可以对scanf等函数进行输入了。

5.我们选择第二行c-Run

6.完美运行。

更多sublime相关知识,请访问sublime教程栏目:https://www.php.cn/tool/sublime/

The above is the detailed content of An article explains how to configure the c compilation environment and test sublime text3. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
The Ultimate Editor Showdown: Sublime Text vs. VS CodeThe Ultimate Editor Showdown: Sublime Text vs. VS CodeApr 21, 2025 am 12:04 AM

SublimeText is suitable for users who pursue speed and simplicity, while VSCode is suitable for users who need rich features and powerful integration capabilities. 1) SublimeText is known for its lightweight and highly customizable, fast and powerful multi-line editing. 2) VSCode is known for its scalability and integration, with built-in Git support and debugging tools, suitable for cross-language development.

Sublime Text and VS Code: Understanding the DifferencesSublime Text and VS Code: Understanding the DifferencesApr 20, 2025 am 12:01 AM

SublimeTextexcelsinspeedandsimplicity,idealforquickeditsandadistraction-freeenvironment,whileVSCodeoffersextensivefeaturesandcustomizationforlargerprojects.SublimeTextislightweightandfast,perfectforfocusedcodingwithasimplecommandpaletteforactionslike

Sublime Text: Coding Features and FunctionalitySublime Text: Coding Features and FunctionalityApr 19, 2025 am 12:06 AM

SublimeText is suitable for programming because it is powerful and flexible. 1) Multiple selection and editing functions allow multiple locations to be modified at the same time to improve reconstruction efficiency. 2) The command panel and shortcut keys provide quick access and custom operations to improve development efficiency. 3) Support regular expressions, macros and plug-ins, suitable for advanced usage and performance optimization.

Sublime Text vs. VS Code: Pricing and LicensingSublime Text vs. VS Code: Pricing and LicensingApr 18, 2025 am 12:02 AM

SublimeText is available for purchase for one time, priced at $70, and is permanently used with a PC; VSCode is free to use, and there is no license fee, but extensions and themes may be charged. When choosing, use requirements and budgets should be considered.

How to run sublimeHow to run sublimeApr 16, 2025 am 09:39 AM

To run Sublime Text, you need to download, install the application, purchase a license (optional), and then launch the application. Create or open a file to start encoding.

How to Chinese sublimeHow to Chinese sublimeApr 16, 2025 am 09:36 AM

Sublime Text can be Chineseized through the following steps: 1. Download the Chinese package; 2. Install the Chinese package; 3. Restart Sublime Text; 4. Set the default language (optional); 5. Verify the Chinese version.

How to delete sublime plug-inHow to delete sublime plug-inApr 16, 2025 am 09:33 AM

There are two ways to delete plugins in Sublime Text: Delete through the Plug-in Manager: Select the plug-in you want to delete and right-click and select "Delete". Manually Delete: Navigate to the user data directory, locate the plugin folder and drag it to the Recycle Bin or Trash.

How to write code with gbk in sublimeHow to write code with gbk in sublimeApr 16, 2025 am 09:30 AM

To write code using GBK encoding in Sublime Text, you need to: 1. Set the project encoding to GBK; 2. Create a new file; 3. Select GBK encoding when saving as; 4. Enter the code using GBK encoding.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software