我想在 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/