c++ - 如何在 sublime 构建文件中添加双引号?

标签 c++ cmd g++ sublimetext2 sublimetext3

我想在 Sublime Text 3 中编译我的 C++ 程序并在 cmd 中运行它。 为此,我创建了一个新的构建系统(工具-->构建系统)。

{
"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",
"variants":
[
    {
        "name": "Run",
        "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}" ,"&&","start", "cmd", "/k", "$file_base_name"],
        "shell": true
    }
] }

执行:

g++ file_location -o file_location && start cmd/k file_location

我想要实现的是(以便它在执行完成后保持屏幕,并且应该在按cmd中的任意键时退出):

g++ file_location -o file_location && start cmd/c "file_location &&pause>nul"

(即用 c 替换 k 并实现双引号)

我已经尝试过\"

它不是传递 " ,而是传递整个 \" ,这会在 cmd 中产生错误。

我应该做什么?

最佳答案

好吧,我自己想出来了。 我应该删除 [] ,以便传递单个字符串而不是数组。现在,要使用双引号,请编写 \" 而不是 "

原始:"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}","&&","start", "cmd", "/k", "$file_base_name"]

修改"cmd": "g++ ${file} -o ${file_path}/${file_base_name} && start cmd/c/"$file_base_name &&pause/""

关于c++ - 如何在 sublime 构建文件中添加双引号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44632662/

相关文章:

python程序在命令行中停止

batch-file - cmd命令以数字顺序转储文件列表

vba - 以管理员身份运行命令提示符命令

c++ - 如何启用帧指针?

c++ - 我们不能混合使用 g++ 和 clang++ 编译的对象(或库)吗?至少在 Mac 上?

c++ - VS 2008 C++ 调试器只能工作一次

c++ - Brainfuck 解释器奇怪的输出

c++ - 什么是 _mm_prefetch() 位置提示?

c++ - 如何在 C++ 中使用 C 空括号函数?

C++类函数返回类型定义,返回一个类