简体   繁体   English

即使在升华文本2中获得输出后如何保持命令提示符打开

[英]How to keep command prompt open even after getting an output in sublime text 2

I'm learning C through K & R and for it I'm using Turbo c++ v 4.5 . 我正在通过K&R学习C,为此我正在使用Turbo c ++ v 4.5 Since it is and ancient compiler I have been searching for better one and came across Sublime Text 2 editor. 由于它是古老的编译器,因此我一直在寻找更好的编译器,并遇到Sublime Text 2编辑器。 I have managed to create a build file and it works fine to capture errors and to give correct output. 我设法创建了一个构建文件,它可以很好地捕获错误并提供正确的输出。
However, after giving an output, command prompt closes itself within a second.I can barely analyze an output. 但是,给出输出后,命令提示符会在一秒钟内关闭自身,我几乎无法分析输出。
I'm using 32-bit windows xp sp3 and MinGW as a compiler . 我正在使用32位Windows XP SP3和MinGW作为编译器
Here is my build file : 这是我的构建文件:

{
"cmd" : ["gcc", "-Wall", "-time", "$file" , "-o",  "$file_base_name"],
"selector" : "source.c",
"shell" : true,
"working_dir" : "$file_path"
}

Steps I follow: 我遵循的步骤:
1.I write program in sublime and build it using above build file. 1.我编写程序并使用上面的构建文件进行构建。
2.Then I go to folder where I have saved my written programs. 2.然后我进入保存了编写程序的文件夹。
3.I find application file(.exe) of program I've written previously and double click it to open. 3.我找到了我之前编写的程序的应用程序文件(.exe),然后双击打开。
4.I enter inputs and command prompt closes itself after a millisecond of printing an output. 4.我输入了输入,并且命令提示符在打印输出一毫秒后自动关闭。

So my question : Is there any way to keep open command prompt for some time or it should be closed when I do it manually. 所以我的问题有什么方法可以使命令提示符保持一段时间,或者在我手动执行时应该将其关闭。 If it is possible please post execution build file for 'C' so I can get output in Sublime itself. 如果可能的话,请为“ C”发布执行构建文件,以便我可以在Sublime本身中获取输出。

Just modify your build system like so: 像这样修改您的构建系统:

{
    "cmd" : ["start", "cmd", "/k", "gcc", "-Wall", "-time", "$file", "-o",  "$file_base_name"],
    "selector" : "source.c",
    "shell" : true,
    "working_dir" : "$file_path"
}

"start", "cmd" opens a new cmd window, and the "/k" options ensures that it stays open after the subsequent command (in this case, gcc ) returns. "start", "cmd"打开一个新的cmd窗口,并且"/k"选项确保它在后续命令(在本例中为gcc )返回后保持打开状态。 You can now scroll through the compiler's output, and run additional commands if you wish, such as executing the just-built program. 现在,您可以滚动查看编译器的输出,并根据需要运行其他命令,例如执行刚刚构建的程序。

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

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