How Sublime runs C language
Sublime Text is a text editor that can run C language code by installing a plug-in. The following are the specific steps:
1. Install the compilation plug-in
- Open Sublime Text and select "Preferences" -> "Package Control".
- Enter "C Builder" in the search bar and press "Install Package".
2. Configure compilation settings
- Select "Preferences" -> "Settings - User".
- Add the following content in the opened file:
<code class="json">{
"c_cpp_properties": {
"configuration": {
"intelliSenseMode": "clang-xcode"
},
"build_systems": [
{
"name": "Run",
"working_dir": "${file_dir}",
"command": "g++ -std=c++11 -Wall -o ${file_base_name} ${file_name}",
"selector": "source.c"
}
]
}
}</code>
Copy after login
3. Run the code
- Open a file in Sublime Text C language source file.
- Select "Tools" -> "Build System" -> "Run".
- Sublime Text will compile and run the code.
Detailed steps:
-
Make sure the g compiler is installed: The g compiler is used to compile C code Command line tools. If it is not installed yet, install it using your system package manager.
-
Install the C Builder plug-in: This plug-in provides syntax highlighting, auto-completion and compilation support for C code.
-
Configure compilation settings: Add the "c_cpp_properties" section in the "User Settings" file to specify compilation commands and settings.
-
Select a build system: In the Build System menu, select Run to build the system.
-
Run Code: Run the code using the Build menu or a keyboard shortcut (for example, Command B on MacOS).
-
Result: After successful compilation, the executable file will be generated in the directory where the source file is located.
The above is the detailed content of How to run c language in sublime. For more information, please follow other related articles on the PHP Chinese website!