Reputation: 113
I'm learning C through K & R and for it I'm using 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. 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.
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.
2.Then I go to folder where I have saved my written programs.
3.I find application file(.exe) of program I've written previously and double click it to open.
4.I enter inputs and command prompt closes itself after a millisecond of printing an output.
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.
Upvotes: 1
Views: 1695
Reputation: 102902
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. You can now scroll through the compiler's output, and run additional commands if you wish, such as executing the just-built program.
Upvotes: 1