简体   繁体   English

如何为 sublime 文本设置 cpp 构建文件?

[英]How to setup cpp build file for sublime text?

I am trying to setup up sublime text for competitive programming.我正在尝试为竞争性编程设置崇高的文本。 I want to pass input from some file say "inputf.in" and get the output in some file say "outputf.txt".我想从某个文件中传递输入,例如“inputf.in”,并在某个文件中获取 output,例如“outputf.txt”。

I found a solution online, but it was for windows.我在网上找到了一个解决方案,但它是针对 windows 的。 I made a few changes to make it work for ubuntu.我做了一些更改以使其适用于 ubuntu。

  1. Open Sublime Text editor and then go to Tools > Build System > New Build System.打开 Sublime Text 编辑器,然后打开 go 到 Tools > Build System > New Build System。
  2. Paste the following code in the file and save it.将以下代码粘贴到文件中并保存。
  3. Name the file as “CP.sublime-build“.将文件命名为“CP.sublime-build”。

For windows适用于 windows

{
"cmd": ["g++.exe", "-std=c++17", "${file}",
        "-o", "${file_base_name}.exe",
        "&&", "${file_base_name}.exe<inputf.in>outputf.out"],
"shell":true,
"working_dir":"$file_path",
"selector":"source.cpp"
}

For ubuntu对于 ubuntu

{
"cmd": ["g++ -std=c++17 ${file} -o ${file_base_name} && ./${file_base_name} < inputf.in > outputf.txt"],
"shell":true,
"working_dir":"$file_path",
"selector":"source.cpp"
}

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

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