起因是刷算法题的时候发现程序中发现程序貌似会卡死
经过测试,发现程序满足三个条件,调试时就会卡住
1.程序中有多个读入(cin或者scanf)
2.终端中黏贴多行数据
3.多个读入之间断点
卡住的表现为点击逐过程后图标变灰,貌似在等待输入,只有通过不断点击暂停与继续才能调试代码
程序运行的视频
源码
#include <iostream>
using namespace std;
int main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
int a=0;
for(int i=1;i<=5;i++){
int c;
scanf("%d",&c);
a++;
cout<<"a:"<<a<<"\n";
}
}
/*
第一种输入方式
1 2 3 4 5
第二种输入方式
1
2
3
4
5
*/
这是使用的tasks.json,调试没有使用到launch.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "D:\\SoftWare\\MinGW\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
尝试的方法
回退插件版本,重装插件,重装环境变量都试过了,都不行.
scanf或者cin都会出问题,取消同步也依然会有问题.
一年以前是可以正常运行的,后来重装了系统,软件环境都重新配置,今天一写就有问题.这样调试代码很难受,要是实在改不好就智能去用Clion了