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

How to run sublime test in c++ language

Apr 03, 2024 pm 12:00 PM
linux sublime c++

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:

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

    #include <iostream>
    
    int main() {
        std::cout << "Hello, world!" << std::endl;
        return 0;
<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 of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to clean up your Linux system How to clean up your Linux system Aug 22, 2025 am 07:42 AM

Removeunusedpackagesanddependencieswithsudoaptautoremove,cleanpackagecacheusingsudoaptcleanorautoclean,andremoveoldkernelsviasudoaptautoremove--purge.2.Clearsystemlogswithsudojournalctl--vacuum-time=7d,deletearchivedlogsin/var/log,andempty/tmpand/var

An In-Depth Guide to Systemd for modern Linux Systems An In-Depth Guide to Systemd for modern Linux Systems Aug 23, 2025 pm 12:02 PM

Systemdisthefirstprocess(PID1)inmodernLinuxsystems,replacingolderinitsystemslikeSysVinitandUpstart,responsibleforbooting,managingservices,devices,logs,andusersessionsthroughasuiteofintegratedtools.2.Itusesunitfiles(.service,.timer,.socket,etc.)todefi

How to pass arguments by reference vs. by value in C How to pass arguments by reference vs. by value in C Aug 22, 2025 am 08:14 AM

In C, the method of passing parameters affects performance, security and modification of original data: use the value when passing basic types or when there is no modification, use the reference when large objects and when modifying, use the reference when reading large objects, and use const reference when reading large objects, avoid returning references to local variables to ensure efficiency and security.

C   call C function from C   example C call C function from C example Aug 25, 2025 am 10:01 AM

To call C functions in C, you need to use extern "C" to prevent name modification. The specific steps are: 1. Write the C function header file hello.h and wrap extern "C" with #ifdef__cplusplus to ensure compatibility; 2. Implement the C function say_hello() and include the header file in the main program main.cpp of C; 3. Use g to compile the C file and link the C target file or directly compile the link; 4. Run the program to correctly output the results, indicating that the C function was called successfully. The whole process needs to ensure that the declaration and compilation method are correct, and the program can run normally and output "CallingCfunc

Which country is the solana currency from? What is the future development? Which country is the solana currency from? What is the future development? Aug 26, 2025 pm 03:18 PM

Solana is a high-performance blockchain project originated from the United States. With its advantages of high speed and low cost, it has developed rapidly in DeFi, NFT, GameFi and other fields. Its ecosystem relies on centralized and decentralized trading platforms to provide liquidity and trading support, especially in the DEX field. The core technology is a combination of historical proof (PoH) and proof of stake (PoS) to achieve high TPS and low fees, but network stability has been challenged many times.

Linux how to check CPU usage Linux how to check CPU usage Aug 22, 2025 pm 04:39 PM

Usetopforareal-timeoverviewofCPUusageandprocesses,whereCPUstatslikeuser,system,andidleareshownatthetopandcanbesortedbyCPUwithShift P;2.Usehtopforamoreuser-friendly,color-coded,andscrollableinterface,installableviasudoaptinstallhtoporsudodnfinstallhto

How to list all files in a directory in C How to list all files in a directory in C Aug 23, 2025 am 09:03 AM

To list all files in the directory, it is recommended to use C 17's std::filesystem library, which is cross-platform and safe; for example, use std::filesystem::directory_iterator to traverse the directory and filter files through is_regular_file(). When compiling, -std=c 17 must be enabled; POSIX's opendir and readdir can be used with dirent.h implementation in Linux/macOS systems that do not support C 17; Windows APIs such as _findfirst and _findnext can be used on Windows; all three methods need to correctly handle errors

How to write exception-safe code in C  ? How to write exception-safe code in C ? Aug 29, 2025 am 08:17 AM

UseRAIItotieresourcemanagementtoobjectlifetimes,ensuringcleanupviadestructorsduringstackunwinding.2.Aimforstrongorno-throwexceptionsafetyguarantees,avoidingthebasicornoguaranteewhenpossible.3.Applythecopy-and-swapidiomtoachievethestrongguaranteebyper

See all articles