search
HomeDevelopment ToolssublimeHow to run c code in sublime

How to run c code in sublime

Aug 23, 2019 pm 02:41 PM
sublime

The following column sublime usage tutorial will introduce how to compile and run c code with sublime. I hope it will be helpful to friends in need!

How to run c code in sublime

How does sublime run c code?

1: Setting up the development environment

C language develops two software, one is a text editing tool, Notepad or EditPlus can be used;

The second one is the C language compiler. Here I use gcc for windows;

Here I paste the download address of gcc for windows on Baidu Cloud Disk.

http://pan.baidu.com/s/1FubYD

2: Setting environment variables:

(1) Extract the file you just downloaded to the root directory of drive C, the folder name is MinGw;

(2) Computer——>(right-click) Properties——>Advanced System Settings——>Environment Variables——>System Variables, select Path and click Edit, change the bin directory path under the MicGw file Copy it out, here it is

C:\MinGW\bin, copy the path to Path, click OK; pay attention to the semicolons before and after the directory, there must be and must be English half-width.

(3) Same as above, create a new system variable lib, corresponding to the lib folder under MicGw; create a new system variable include, corresponding to the include folder under MicGw;

That’s it, we Even if the basic environment for C language development has been set up;

compile the Hello.c file we just saved and use the command gcc Hello.c -o Hello.exe

It means to use the gcc command to compile the Hello.c file we just wrote into the Hello.exe executable file. At this time, when you return to the directory corresponding to the source file, you will find that there will be a Hello.exe file;

Double-click Hello.exe directly and find that there will be a flash, and then nothing. We still check directly in the command prompt, Hello.exe, and find that two words are typed out: Hello, world!

3: sublime configuration C language environment

1 , sublime->Tools->Compilation System->New Compilation System

Enter the following configuration information:

{
"working_dir": "$file_path",
"cmd": "gcc -Wall \"$file_name\" -fexec-charset=gbk -o \"$file_base_name\" -std=c99",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c",
"variants":
[
{
"name": "Run",
            "shell_cmd": "gcc -Wall \"$file\" -fexec-charset=gbk -o \"$file_base_name\" -std=c99 && start cmd /c \"${file_path}/${file_base_name} & pause\""
}
]
}
Select CodeCopy

Save as myc.sublime-build

2, Just choose your myc.sublime-build as the compilation system

● Solve the problem that the for statement cannot be compiled (-std=c99)

● Solve the problem that the Chinese output in C language is garbled (-fexec-charset =gbk)

The above is the detailed content of How to run c code in sublime. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:cnntt. If there is any infringement, please contact admin@php.cn delete
Sublime Text: Exploring Its CapabilitiesSublime Text: Exploring Its CapabilitiesApr 26, 2025 am 12:10 AM

SublimeText is a powerful text editor suitable for a variety of programming languages ​​and file formats. 1. Multiple selection and editing functions allow multiple locations to be modified at the same time to improve editing efficiency. 2. The command panel is accessed through shortcut keys and performs various operations, such as formatting code and managing plug-ins.

Sublime Text Evaluation: The Free to Try OptionSublime Text Evaluation: The Free to Try OptionApr 25, 2025 am 12:08 AM

SublimeText is available for free, but every once in a while, a purchase prompt pops up. 1) It supports multiple programming languages, has a simple interface and a powerful plug-in ecosystem. 2) Users can optimize the user experience by closing unnecessary plug-ins, regularly updating and using shortcut keys.

Sublime Text: From Beginners to ExpertsSublime Text: From Beginners to ExpertsApr 24, 2025 am 12:14 AM

SublimeText is suitable for beginners and experts. 1. Shortcut keys and command panels improve efficiency. 2. Package manager extension function. 3. Customize the details of the configuration file. 4. Multiple selection and editing functions are used to refactor code. 5. Search and replace function positioning and modify code. 6. Project management and version control integration facilitate project management.

Sublime Text: The Price of PerformanceSublime Text: The Price of PerformanceApr 23, 2025 am 12:09 AM

The performance benefits of SublimeText are fast startup, multi-threading, and a rich plug-in ecosystem, but at the expense of high license fees, complex plug-in configurations, and potentially increased memory footprint.

Sublime Text vs. VS Code: User Interface and User ExperienceSublime Text vs. VS Code: User Interface and User ExperienceApr 22, 2025 am 12:07 AM

SublimeText is suitable for users who pursue simplicity and highly customized, while VSCode is more suitable for users who need one-stop service and better user experience. The SublimeText interface is simple and complex, suitable for advanced users; the VSCode interface is modern and easy to use, suitable for beginners and team collaboration.

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.

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

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),