ifstream与子文件夹中的文件

时间:2018-02-23 12:42:20

标签: c++

如果文件位于子文件夹中,我打印文件的所有行都有问题。我正在使用提升。

#include <iostream>
#include <fstream>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#inlude <vector>
...

sample.gz是同一个文件,只在两个不同的位置。

    std::ifstream="files/dir/sample.gz"; // file is ok but no line is printed
    std::ifstream="sample.gz"; // file is printed line by line

    std::ifstream ifile(infilez, std::ios::in | std::ios_base::binary);
        boost::iostreams::filtering_istream in;
        in.push(boost::iostreams::gzip_decompressor());
        in.push(ifile);
        std::vector<std::string> strs;
        boost::split(strs,line,boost::is_any_of("\t"));


std::string name,lines,content;
    std::stringstream ss;
    int cpt=0;

    while( std::getline( in, line ).good() ){
           std::cout << line << "\n" << content << std::endl;          
        }

    ....

0 个答案:

没有答案