方法1
打开.vscode中launch.json文件
修改下面三个配置
"program":"C:\\Windows\\System32\\cmd.exe",
"args": ["/C","${fileDirname}\\${fileBasenameNoExtension}.exe","&","pause"],
"externalConsole": true,
以非调试模式运行,ctrl+F5
方法2
打开.vscode中launch.json文件
修改"externalConsole": true,
在main函数中最后加入getchar()函数
注:方法2如果只修改externalConsole为true终端会一闪而过