zoukankan      html  css  js  c++  java
  • 25.文件当做内存来操作

     1 #define _CRT_SECURE_NO_WARNINGS
     2 #include <iostream>
     3 #include <boost/interprocess/file_mapping.hpp>
     4 #include <boost/interprocess/mapped_region.hpp>
     5 #include <fstream>
     6 #include <cassert>
     7 #include <cstdlib>
     8 
     9 using namespace std;
    10 using namespace boost;
    11 
    12 //#pragma comment(lib,"libboost_date_time-vc141-mt-sgd-x32-1_66.lib")
    13 
    14 void main()
    15 {
    16     //创建读写模式
    17     boost::interprocess::mode_t mode = boost::interprocess::read_write;
    18     char path[50] = "1.txt";
    19     //文件映射
    20     boost::interprocess::file_mapping fm(path, mode);
    21     //用region访问
    22     boost::interprocess::mapped_region region(fm, mode, 0, 0);
    23 
    24     char *pbegin = reinterpret_cast<char *>(region.get_address());
    25     char *pend = pbegin + region.get_size();
    26     for (char *p = pbegin; p != pend; p++)
    27     {
    28         cout << *p << endl;
    29     }
    30     cin.get();
    31 }
  • 相关阅读:
    Eclipse中项目去除Js验证
    Web安全扫描工具
    Oracle-定时任务
    About_Return
    About_php_封装函数
    About_PHP_函数
    About_PHP_验证码的生成
    About_PHP_文件的上传
    About_MySQL Select--来自copy_03
    About_AJAX_03
  • 原文地址:https://www.cnblogs.com/xiaochi/p/8690904.html
Copyright © 2011-2022 走看看