Chinaunix首页 | 论坛 | 博客
  • 博客访问: 173278
  • 博文数量: 47
  • 博客积分: 3053
  • 博客等级: 少校
  • 技术积分: 451
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-01 04:33
个人简介

malware/APT detection, silicon valley, entrepreneur, CTO, start-up operation, team build, Nanjing/Beijing, if you want to do creative things, join the adventure.

文章分类

全部博文(47)

分类: C/C++

2008-05-01 06:43:37

#include "string.h"
#include <iostream>
#include <fstream>

using namespace std;


int main(int argc, char** argv){
    int n[] = {1,2,3,4,5};

    ofstream out("test.txt", ios::out | ios::binary | ios::trunc);
    if(! out){
        cout << "cannot open out\n";return 1;
    }

    out.write((char*)&n, sizeof n);
    out.close();
    
    for(int i=0; i<5; i++){
        n[i] = 0;
    }

    ifstream in("test.txt", ios::in | ios::binary);
    if(! in){
        cout << "cannot open in\n";return 1;
    }

    in.read((char*) &n, sizeof n);

    for(i=0; i<5; i++){
        cout << n[i] << endl;
    }

    in.close();
    return 0;
}

阅读(1044) | 评论(0) | 转发(0) |
0

上一篇:reverse string and sentence

下一篇:Exception

给主人留下些什么吧!~~