Sublime Text 启动单独的命令窗口 (C/C++) [英] Sublime Text launch separate command window (C/C++)
问题描述
我正在尝试执行 Stephen G. Kochan 在 C 中编程 作为练习,并熟悉 C 的一些更精细的细节(我没有上过计算机科学学校)(在 Windows 8 机器).
I am trying to do all the programs in Programming in C by Stephen G. Kochan as an exercise and to familiarize myself with some of the finer details (I didn't go to school for computer science) of C (on a Windows 8 machine).
很多书都是简单的程序,我想用Sublime Text(相对于 Code::Blocks,我一直在使用 openFrameworks).是否有一种简单的方法可以在编译后为程序启动单独的命令窗口.
A lot of the book is simple programs and I'd like to enter the programs with Sublime Text (as opposed to Code::Blocks, which I have been using with openFrameworks). Is there an easy way to launch a separate command window for a program after it is compiled.
这有点hacky,但我更改了构建的运行"版本以启动已编译的程序
It's kind of hacky, but I changed the "run" version of build to launch the compiled program
"cmd": ["${file_base_name}.exe"]
但显然,Sublime Text 文档说GUI 被抑制.
but apparently, the Sublime Text documentation says that GUI's are suppressed.
我想做的是启动一个单独的命令提示符窗口.主要原因是 scanf
不会停止输入.如果有快速解决方法,请告诉我:
What I want to do is launch a separate command prompt window. The primary reason is that scanf
does not halt for input. Let me know if there is a quick workaround:
- Sublime Text 中的一些解决方法(我不知道的设置)
- 如何更改构建文件以启动实际窗口
- 一些在 C 中轻松启动单独窗口的方法
推荐答案
{
"cmd": ["start", "cmd", "/c $file_base_name.exe"],
"selector": "text.c",
"shell": "true"
}
cmd start
命令打开传递给它的命令的新窗口.
请注意,为了防止窗口在程序结束时立即关闭,您将使用 system("pause");
或 getch();
结束它们,或将/c 替换为/k 以保持 cmd 运行.
The cmd start
command opens a new window of the command passed to it.
Note that to keep the window from closing immediately at the end of your programs, you'll have end them with system("pause");
or getch();
, or replace /c with /k to keep cmd up.
经过更多挖掘和调试:
"cmd": ["start", "cmd", "/c", "$file_base_name.exe & pause"]
我在使用 Java 时遇到了同样的问题,试图创建一个 Run Variant,最终得到了这个:
I had the same issue with Java, trying to create a Run Variant, and eventually came out with this:
"variants":
[
{
"cmd": ["start", "cmd", "/c", "java $file_base_name & pause"],
"name": "Run"
}
]
这篇关于Sublime Text 启动单独的命令窗口 (C/C++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!