outfile << pContent;//不可以用这个,因为不能写完全,比如遇到字符串中出现/0就终止了

bool CTestEn_DecryptDLLDlg::WriteDataFile(CString strFileName, char *pContent, int nLen)
{
ofstream outfile(strFileName, ios::out | ios::binary | ios::ate | ios::app);
if (!outfile)
{
AfxMessageBox(_T("Unable to open outfile"));
return false;
} //for (int i = 0; i < nLen; ++i)
//{
// outfile << pContent[i];
//}
//outfile << pContent;//不可以用这个,因为不能写完全,比如遇到字符串中出现/0就终止了
outfile.write(pContent, nLen);
outfile.close();
} bool CTestEn_DecryptDLLDlg::ReadDataFile(CString strFileName, char *pContent, int &nLen)
{
ifstream inFile(strFileName, ios::in | ios::binary);
if (!inFile)
{
AfxMessageBox(_T("Unable to open inFile"));
return false;
} inFile.seekg(, ios::beg);
//int i = 0;
//while (!inFile.eof())
//{
// inFile.get(pContent[i]);
// ++i;
//}
//nLen = i - 1;
memset(pContent, , nLen);//初始化FileContent
inFile.read(pContent, nLen);//读取数据 inFile.close();//关闭ifstream对像
return true;
}

ifstream 和 ofstream 用法。的更多相关文章

  1. fstream,ifstream,ofstream 详解与用法

    fstream,istream,ofstream 三个类之间的继承关系 fstream :(fstream继承自istream和ofstream)1.typedef basic_fstream< ...

  2. 关于fstream、ifstream、ofstream读写文本文件、二进制文件详解

    fstream.ifstream.ofstream是c++中关于文件操作的三个类 fstream类对文件进行读操作和写操作 打开文件 fstream fs("要打开的文件名",打开 ...

  3. 详解文件操作(ifstream、ofstream、fstream)[转]

    C++ 通过以下几个类支持文件的输入输出: ofstream: 写操作(输出)的文件类 (由ostream引申而来) ifstream: 读操作(输入)的文件类(由istream引申而来) fstre ...

  4. C++文件操作详解(ifstream、ofstream、fstream)

    C++ 通过以下几个类支持文件的输入输出: ofstream: 写操作(输出)的文件类 (由ostream引申而来) ifstream: 读操作(输入)的文件类(由istream引申而来) fstre ...

  5. 【学习笔记】C++文件操作详解(ifstream、ofstream、fstream)

    C++ 通过以下几个类支持文件的输入输出: ofstream: 写操作(输出)的文件类 (由ostream引申而来) ifstream: 读操作(输入)的文件类(由istream引申而来) fstre ...

  6. ofstream和ifstream详细用法

    ASCII和二进制文件的输入输出 First:包含头文件#include <fstream> ASCII输入: 首先要创建一个in-stream对象:ifstream fin(" ...

  7. 转载:fstream和ifstream详细用法

    文件 I/O 在C++中比烤蛋糕简单多了.在这篇文章里,我会详细解释ASCII和二进制文件的输入输出的每个细节,值得注意的是,所有这些都是用C++完成的. 一.ASCII 输出 为了使用下面的方法, ...

  8. ofstream和ifstream

    ofstream(输出流)是从内存到硬盘,ifstream(输入流)是从硬盘到内存. //#include<iostream> #include<fstream> using ...

  9. 学习c++ofstream和ifstream

    定义数据流对象指针 对文件进行读写操作首先必须要定义一个数据流对象指针,数据流对象指针有三种类型,它们分别是: Ifstream:表示读取文件流,使用的时候必须包含头文件"ifstream& ...

随机推荐

  1. ubuntu 14.04 安装redis5.0.3

    redis下载地址:http://download.redis.io/releases/ 新建Redis目录,下载Redis 安装包: mkdir rediscd rediswget http://d ...

  2. 转载:RESTful API 设计指南

    http://www.ruanyifeng.com/blog/2014/05/restful_api.html 网络应用程序,分为前端和后端两个部分.当前的发展趋势,就是前端设备层出不穷(手机.平板. ...

  3. GRASP (职责分配原则)

    要学习设计模式,有些基础知识是我们必须要先知道的,设计模式是关于类和对象的一种高效.灵活的使用方式,也就是说,必须先有类和对象,才能有设计模式的用武之地,否则一切都是空谈,那么类和对象是从那冒出来的呢 ...

  4. 删除node_modules

    // 删除node_modules $ rm -rf node_modules

  5. SetParent

    1.http://bbs.csdn.net/topics/390672855 该帖子中 第15楼: “ MSDN里面说了:if hWndNewParent is not NULL and the wi ...

  6. SVG基础图形和D3.js

    使用D3.js画一个SVG 的 圆 circle 可以使用如下代码创建: <svg width="50" height="50"> <circ ...

  7. C#对实体进行JSON序列化时枚举的处理

    实体类如下: public enum ESex { Boy, Girl } public class Person { public String Name { get; set; } public ...

  8. 雷林鹏分享:Ruby 判断

    Ruby 判断 Ruby 提供了其他现代语言中很常见的条件结构.在这里,我们将解释所有的条件语句和 Ruby 中可用的修饰符. Ruby if...else 语句 语法 if conditional ...

  9. Vue.js教程--基础2(事件处理 表单输入绑定

    事件处理 表单输入绑定 事件处理 监听v-on 监听 DOM 事件,并在触发时运行一些 JavaScript 代码. 可以在v-on:click=''加内联语句. 有时也需要在内联语句处理器中访问原始 ...

  10. hdu-6324-博弈

    Problem F. Grab The Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Ja ...