Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code vscode代码运行器:在外部终端中执行代码并暂停_Visual Studio Code - Fatal编程技术网

Visual studio code vscode代码运行器:在外部终端中执行代码并暂停

Visual studio code vscode代码运行器:在外部终端中执行代码并暂停,visual-studio-code,Visual Studio Code,我的意图是 使代码在外部终端中运行 暂停该终端,以便查看结果 在集成终端中运行代码的原始代码运行程序设置为 "code-runner.executorMap":{ "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", ... } 我已成功使用以下代码在外部终

我的意图是

  • 使代码在外部终端中运行
  • 暂停该终端,以便查看结果
  • 在集成终端中运行代码的原始代码运行程序设置为

    "code-runner.executorMap":{  
           "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
           ...  
    }
    
    我已成功使用以下代码在外部终端中运行代码:

    "code-runner.executorMap":{  
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && start $fileNameWithoutExt.exe",  
         ...  
    }
    
    但是终端消失得太快了,我看不到结果。
    我在上面的链接上尝试了第四个答案:

    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && Start pwsh -Command  \"& {.\\$fileNameWithoutExt.exe; pause}\"",
    
    但它不适合我,正如vscode所说:找不到与参数名“Command”匹配的参数

    我也试过了

    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && start $fileNameWithoutExt.exe && pause",
    
    但外部终端仍然消失,“暂停”使集成终端暂停。
    然后我试着

    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && start cmd /k $fileNameWithoutExt.exe"
    
    我以为“start cmd”会打开新的命令提示符,“/k”会让它继续运行。
    ()

    它仍然不起作用,vscode说:找不到接受参数
    hw3.exe
    的位置参数。(hw3是我的文件名)

    我知道终端中有
    code runner:run
    -是否在
    Files>Preferences>Settings>User
    中的集成终端设置中运行代码,但我的工作区中有几个文件夹,我只打算在外部终端中为此特定文件夹运行代码。因此,我一直选中该设置,并使用此文件夹特有的settings.json


    谢谢你的时间,请保持安全

    这应该可以做到:

        "code-runner.executorMap":{
            "cpp": "cd $dir && g++ -O2 -std=c++17 $fileName -o $fileNameWithoutExt && start cmd \"/k ; $fileNameWithoutExt\""
        },
    

    非常感谢你!这个答案适用于cpp,将“cpp”改为“c”后,它也适用于c