Home  >  Article  >  Development Tools  >  How to run c language in sublime

How to run c language in sublime

下次还敢
下次还敢Original
2024-04-03 16:15:151328browse

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>

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:

  1. 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.
  2. Install the C Builder plug-in: This plug-in provides syntax highlighting, auto-completion and compilation support for C code.
  3. Configure compilation settings: Add the "c_cpp_properties" section in the "User Settings" file to specify compilation commands and settings.
  4. Select a build system: In the Build System menu, select Run to build the system.
  5. Run Code: Run the code using the Build menu or a keyboard shortcut (for example, Command B on MacOS).
  6. 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn