Answer the question
In order to leave comments, you need to log in
How to adequately delay console in C++ Sublime Text?
I decided to try something simple instead of all these cumbersome IDEs. I decided to attach MinGW to Sublime Text so that I could compile and run .cpp directly from it. Everything works, but there is such an obvious problem: after the program ends, the console immediately closes, and does not wait for Enter, well, this is understandable, it should be, and it is even treated using system("pause"). Noo, this is very unpleasant, as a perfectionist I just can't do it. Everything works like this:
1) You install Sublime Text
2) You install MinGW
3) You need to go to Control Panel->System and Security->System->Advanced system settings->Environment Variables
4) In the "system variables" section, find the variable " path".
5) Add to it, separated by a semicolon (everywhere without spaces), the path where the MinGW compiler is located, usually it is in the root of the C drive in the MinGW-> bin folder. Or in Windows 10 (maybe not only), you can simply add it to the list.
After that we need to add Build System (In sublimeText - Tools->Build system -> and select). There is a ready-made system there, but I found how to open the console, and so that everything is done there:
1) You need to create a file
"c:\Users\%UserName%\AppData\Roaming\Sublime Text 3\Packages\User\%name Build System%.sublime-build (I have MinGW.sublime-build)"
2) Open this file with notepad and paste it there
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,
"encoding": "1251",
"variants":
[
{
"name": "Run",
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "${file_base_name}"],
"shell": true
}
]
}
Answer the question
In order to leave comments, you need to log in
As I understand it, you have nothing against the "pause" command, but simply don't want to write system("pause") in every .cpp file. In this case, you can line:
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "${file_base_name}"],
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/K", "${file_path}/${file_base_name} && pause 'TTL'>Nul && exit"],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question