下截boost库,解压,不需要编译,

配置属性》C/C++》常规》附加包含目录,添加boost解压后的目录地址,如下图,使用boost iostream写文件 

打开vs2012,新建一个控制台应用程序, 

源代码如下: 

#include <ostream>

#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/stream.hpp>
namespace io = boost::iostreams;
int main()
{
    io::stream_buffer<io::file_sink> buf("log.txt");
    std::ostream                     out(&buf);

    out << "xxxxxx" ; 

    // out writes to log.txt
}

 

编译成功并执行后,打开log.txt,发现文件里会包含输出的内容 

相关文章:

  • 2022-12-23
  • 2022-03-11
  • 2022-12-23
  • 2021-11-15
  • 2022-02-18
  • 2021-06-16
  • 2021-09-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案