简体   繁体   English

如何在 Sublime Text 的命令提示符下运行 C++?

[英]How to run C++ in command prompt from Sublime Text?

The build systems bundled with Sublime Text run the program in the small window below the text editor pane.与 Sublime Text 捆绑的构建系统在文本编辑器窗格下方的小窗口中运行程序。 This is inconvenient to some as user input cannot be taken in such a case.这对某些人来说是不方便的,因为在这种情况下不能接受用户输入。

What is the build system script to execute the program in a separate cmd window directly from Sublime Text?直接从 Sublime Text 在单独的cmd窗口中执行程序的构建系统脚本是什么?

Go to Tools > Build System > New Build System...' and paste the following in the file:转到“ Tools > Build System > New Build System...'并将以下内容粘贴到文件中:

{
    "cmd": ["g++.exe", "-std=c++11", "-o", "$file_base_name", "$file", "&&", "start", "cmd", "/c", "$file_base_name & echo. & echo. & pause"],
    "shell": true,
    "selector": "source.c++"
}

Save the file, and while compiling your C++ code from Sublime, choose the newly created build system from Tools > Build System保存文件,并在从 Sublime 编译 C++ 代码时,从Tools > Build System选择新创建的Tools > Build System

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM