开始使用vscode作为常用编辑器,听说git bash作为程序终端十分不存,但最近在调试C++时遇到了问题:
在编译后调试如下程序时(使用"./program.exe"命令)
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main()
{
char buffer[256];
ifstream in("test.txt");
if (!in.is_open())
{
cout << "Error opening file";
exit(1);
}
while (!in.eof())
{
in.getline(buffer, 100);
cout << buffer << endl;
}
return 0;
}
起初我以为是程序的问题,但在如下另代码中同样失效
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream f("D:\\6.Code\\CPP\\arrary_ah\\test.txt", fstream::in | fstream::out);
cout << "hello" << endl;
return 0;
}
但以上程序在cmd中直接"program"或"program.exe"可以执行,于是排除vscode和程序错误的问题,确定是git bash的问题,但将有关fstream的命令去掉却能正常执行.
谷歌半天没有相关结果,想请了解的或愿意帮忙的能帮我解答或复现一下吗?如果这是git bash的问题那么有什么适合vscode的其他终端吗?(不是很想用cmd或powershell)
cygwin