Running C/C++ Codes in Sublime Text
There are several IDE’s for coding in C/C++. Many text editors are also used for coding. Among them, Sublime text is the mostly used one. Its is popular for its features.
In this blog post, I have discussed the steps you need to complete before you run a C/C++ code in Sublime Text where the inputs are from a input file and outputs are to a output file rather using “freopen and file related functions in C/C++”.
Install Sublime Text in Windows:
Install Sublime Text in Linux:
JSON for Package New Build Package in Sublime Text:
{
"cmd" : ["g++ -std=c++14 '$file_name' -o '$file_base_name' && timeout 4s ./'$file_base_name'<in.txt>out.txt"],
"selector" : "source.c, source.cpp",
"shell": true,
"working_dir" : "$file_path"
}
You can change the in.txt and out.txt with your desired input and output file name. Input file is responsible for the inputs in the code at runtime.