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

How to run sublime test in c++ language

下次还敢
下次还敢Original
2024-04-03 12:00:22736browse

The steps to run a C program in Sublime Text are as follows: Install MinGW or Clang compiler Set up the corresponding build system Write and save the C code with ".cpp" extension Press Ctrl B or Cmd B to build the program Press Ctrl F5 or Cmd F5 to run the program

How to run sublime test in c++ language

How to run C language in Sublime Text

Run Steps of C program

Running a C program in Sublime Text requires the following steps:

  1. Install the compiler:First, you need to install a C compiler device. It is recommended to use MinGW or Clang.
  2. Set up the build system: Next, you need to set up a build system for Sublime Text. This tells Sublime Text how to compile and run the program. Tools -> Build System -> New Build System..., and then select the appropriate compiler.
  3. Write and Save Code: In Sublime Text, write and save your C code. Use files with the ".cpp" extension.
  4. Build the program: Press Ctrl B (Windows/Linux) or Cmd B (Mac) to build the program. This will compile the code and generate an executable file.
  5. Run the program: Press Ctrl F5 (Windows/Linux) or Cmd F5 (Mac) to run the program. This will open a terminal window and run the executable file within it.

Detailed instructions

  • Compiler installation:

    • MinGW: https://sourceforge.net/projects/mingw-w64/
    • Clang: https://clang.llvm.org/
  • Build system settings:

    • MinGW: `json
      {
      "cmd": ["g ", "-std=c 17", "${file}"],
      "file_regex": "^(..1):([0-9] ):? ([0-9] )?:? (.)$",
      "selector": "source.cpp"
      }

    • Clang:

      <code class="json">{
      "cmd": ["clang++", "-std=c++17", "${file}"],
      "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
      "selector": "source.cpp"</code>
  • Code writing:

    <code class="cpp">#include <iostream>
    
    int main() {
        std::cout << "Hello, world!" << std::endl;
        return 0;</code>
<code>* **构建和运行:**
* **Ctrl + B** / **Cmd + B**(构建)</code>

  1. :

The above is the detailed content of How to run sublime test in c++ language. 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