0

当我在“essential c++”中编写练习 3.1 的代码时,STL 复制功能根本不起作用,没有任何编译错误。

#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <iterator>
#include <string>
#include <algorithm>
#include <vector>

int main(int argc, char const *argv[])
{
    std::ifstream input_file("input.txt");
    if (!input_file)
    {
        std::cerr<<"!! unable to open the necessary files.\n";
        return -1;
    }
    std::istream_iterator<std::string> is(input_file);
    std::istream_iterator<std::string> eof;

    std::vector<std::string> testStrVec = {"as","kg","mk"};
    std::vector<std::string> text;
    std::copy(testStrVec.begin(), testStrVec.end(), std::back_inserter(text));



    return 0;
}

当我调试程序时,执行复制功能后文本向量仍然为空。

4

0 回答 0