将 3 个文件合并在一起,合并相同的三个文件时效果很好,但合并 3 个不同的文件时,它不想读取第 3 个文件
Merging 3 files together, works fine when merging the same three files but when mergin 3 different files, it doesnt want to read the 3rd file
所以标题说明了一切,我正在尝试将 3 个单词列表连接在一起,但是由于某种原因它不想阅读第三个列表,
第一个单词表单词:
nand
减
第二个单词表单词:
也不
负面
第三个单词表单词:
异或
加上
void merge3(string MFile3)
{
string file1name, file2name,file3name, outfilename, word1, word2, word3;
cout << "Enter name of first file: ";
cin >> file1name;
cout << "Enter name of second file: ";
cin >> file2name;
cout << "Enter name of third file: ";
cin >> file3name;
cout << "Enter name of output file: ";
cin >> outfilename;
ofstream inFileFour(outfilename.c_str());
ifstream inFileOne(file1name.c_str());
while (inFileOne >> word1) {
ifstream inFileTwo(file2name.c_str());
while (inFileTwo >> word2) {
ifstream inFileThree(file2name.c_str());
while (inFileThree >> word3) {
inFileFour << word1 << word2 << word3 << endl;
}
inFileThree.close();
}
inFileTwo.close();
}
inFileOne.close();
inFileFour.close();
}
有错误的词表,前2个词表显示,第3个不显示
包含所有可能组合的单词列表期望与文件
如果有人能让我知道这里发生了什么那就太好了,我愿意接受建议。
第三个文件没有被读取,您正在再次读取第二个文件:
ifstream inFileThree(file2name.c_str());
所以标题说明了一切,我正在尝试将 3 个单词列表连接在一起,但是由于某种原因它不想阅读第三个列表,
第一个单词表单词:
nand
减
第二个单词表单词:
也不
负面
第三个单词表单词:
异或
加上
void merge3(string MFile3)
{
string file1name, file2name,file3name, outfilename, word1, word2, word3;
cout << "Enter name of first file: ";
cin >> file1name;
cout << "Enter name of second file: ";
cin >> file2name;
cout << "Enter name of third file: ";
cin >> file3name;
cout << "Enter name of output file: ";
cin >> outfilename;
ofstream inFileFour(outfilename.c_str());
ifstream inFileOne(file1name.c_str());
while (inFileOne >> word1) {
ifstream inFileTwo(file2name.c_str());
while (inFileTwo >> word2) {
ifstream inFileThree(file2name.c_str());
while (inFileThree >> word3) {
inFileFour << word1 << word2 << word3 << endl;
}
inFileThree.close();
}
inFileTwo.close();
}
inFileOne.close();
inFileFour.close();
}
有错误的词表,前2个词表显示,第3个不显示
包含所有可能组合的单词列表期望与文件
如果有人能让我知道这里发生了什么那就太好了,我愿意接受建议。
第三个文件没有被读取,您正在再次读取第二个文件:
ifstream inFileThree(file2name.c_str());