#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
std::ifstream ifs;
std::ofstream ofs;
std::string input;
// ask for input file and output file
std::cout << "Enter input file name: " << std::endl;
std::cin >> input;
ifs.open(input);
if (ifs.fail()) {
std::cout << "Failed to open the input file." << std::endl;
return 1;
}
std::cout << "Enter output file name: " << std::endl;
std::cin >> input;
ofs.open(input);
if (ofs.fail()) {
std::cout << "Failed to open the output file for write access." << std::endl;
return 1;
}
// read the count of node and link
int node_count = 0;
int link_count = 0;
ifs >> node_count;
ifs >> link_count;
// alloc and zero memory
int *nodes = new int[node_count];
int *links = new int[link_count];
for (int i = 0; i < node_count; ++i) { nodes[i] = 0; }
for (int i = 0; i < link_count; ++i) { links[i] = 0; }
while (!ifs.eof()) {
bool gg = false;
for (int i = 0; i < link_count; ++i) {
ifs >> links[i];
nodes[(links[i] / 10) - 1] = 1;
nodes[(links[i] % 10) - 1] = 1;
}
for (int i = 0; i < node_count; ++i) {
if (nodes[i] == 0) {
gg = true;
break;
}
}
if (!gg) {
for (int i = 0; i < link_count; ++i) {
ofs << links[i] << " ";
}
ofs << std::endl;
}
}
delete[] nodes;
delete[] links;
ifs.close();
ofs.close();
}
当我编译这个c ++程序并运行得到这个错误。没有匹配调用std :: basicifstream :: open(st ...,有人可以帮我吗?这是我不应该使用std ::?并直接使用ifs直接