【问题标题】:Run C++ file with input in Sublime Text 2在 Sublime Text 2 中运行带有输入的 C++ 文件
【发布时间】:2013-04-05 09:20:20
【问题描述】:

C++ 源代码编译后,我想通过 sublime text 命令使用输入文件运行它。如何做到这一点?

【问题讨论】:

标签: c++ sublimetext2


【解决方案1】:

如果你的意思是你的 C++ 构建文件之后的参数,我已经找到了一种方法来以一种狡猾的方式做到这一点......我为 c++11 创建了一个新的构建系统并添加了输入文件(见下面的 input_file)到运行部分。

{
"cmd": ["g++", "-Wall", "-Wextra", "-pedantic", "-std=c++0x",   "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",

"variants":
[
    {
        "name": "Run",
        "cmd": ["bash", "-c", "g++ -Wall -Wextra -pedantic -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}' input_file"]
    }
]}

将文件(例如C++11.sublime-build)保存在$HOME/.config/sublime-text-2/Packages/User 中。选择 Build System C++11,它应该可以完成这项工作。

【讨论】:

  • 做到了。谢谢@RicLeal!
猜你喜欢
  • 2014-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-30
  • 1970-01-01
  • 2014-06-09
  • 2013-04-13
  • 2016-05-20
相关资源
最近更新 更多