Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8294757
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类: C/C++

2006-06-09 10:14:21

//使用(C++库)ofstream写文件数据
//simple example
#include
#include
using namespace std;
#ifdef WIN32
#define TEST_FILE "c:\\shi\\aaa.txt"
#else
#define TEST_FILE "/tmp/test.txt"
#endif
void test()
{
    //ofstream ofs;
    //ofs.open(TEST_FILE);
    ofstream ofs(TEST_FILE);
    char ch = '#';
    const char buf[] = "1234567890";
    ofs.put(ch);//simple
    ofs.write(buf, sizeof(buf));
    ofs.put(ch);
    ofs.close();
}
int main(int argc, char* argv[])
{
    test();
    return 0;
}
阅读(1481) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~