Build System Sublime Text 3 Ubuntu

I have recently moved from windows to ubuntu 20.04. I need a build system for sublime text 3 for ubuntu which includes followings features :

  1. It should build and run the current opened file in C++14
  2. It should take input from a file named “input.txt” and show the output in sublime console.

There are many available sublime build system but none of them has the feature 2.All of them show results to another file not in sublime console. Thank you for your time and excuse my bad english.

{

“cmd” : [“g++ -std=c++17 $file_name -o $file_base_name && timeout 10s ./$file_base_name</home/ashish/code/input.in>/home/ashish/code/output.out”],
“selector” : “source.cpp”,
“shell”: true,
“working_dir” : “$file_path”
}

This is my current build system. It takes care of inf loops by terminating the program after 10 secs.I would say instead of using sublime console for output use a txt file for output. I mean this kind of layout

Yeah I saw this layout before .But I prefer sublime console. Thank you for your time and effort

freopen("input.txt", "r", stdin);
Just add this line in your main() function and it will be fine.

I’m on windows but I use WSL with ubuntu 20.04 as the distro so this should work.

REFERENCE

SUBLIME BUILD FOR PRINTING IN CONSOLE
{
  "cmd" : ["bash", "-c", "g++ ${file_name} -o ${file_base_name} && ./${file_base_name}<input.txt"],
	"shell":true,
	"working_dir":"$file_path",
}
SUBLIME BUILD FOR PRINTING IN OUTPUT.TXT
{
  "cmd" : ["bash", "-c", "g++ ${file_name} -o ${file_base_name} && ./${file_base_name}<input.txt>output.txt"],
	"shell":true,
	"working_dir":"$file_path",
}

Though I recommend using output.txt format as it facilitates printing the debugging output in the console and standard output in output.txt
PS: You don’t have to use that freopen stuff for taking input from input.txt

@cubefreak777 Thanks brother.This is what I was looking at. But it seems your build system is not compiling in C++14 rather it is using C++98.Can you change it for C++14 or C++17 ?

Try this

{
    "cmd" : ["g++ ${file_name} -o ${file_base_name} && ./${file_base_name}<input.txt"],
	"shell":true,
	"working_dir":"$file_path",
}

let me know if this doesn’t works either

@cubefreak777 Which IDE You Use?? Is It Sublime In PIC

Yes

@cubefreak777 With Which Theme?

Please Tell @cubefreak777

Night Owl with FixedSys font

Thanks @cubefreak777 You Are Awsome