会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
流云の剑舞秋风
吾生也有涯 而知也无涯
博客园
首页
新随笔
联系
订阅
管理
公告
读写2进制流文件
//
读写2进制流文件
#include
<
fstream.h
>
#include
<
iostream.h
>
#include
<
stdlib.h
>
void
main()
{
ofstream f1(
"
wr1.dat
"
);
if
(
!
f1)
{
cerr
<<
"
wr1.dat file not open!
"
<<
endl;
exit(
1
);
}
//
f1.seekp(beg);
for
(
int
i
=
0
;i
<
21
;i
++
)
f1
<<
i
<<
"
"
;
f1.close();
ifstream f2(
"
wr1.dat
"
,ios::
in
|
ios::nocreate);
if
(
!
f1)
{
cerr
<<
"
wr1.dat file not open!
"
<<
endl;
exit(
1
);
}
int
x;
while
(f2
>>
x)
cout
<<
x
<<
'
'
;
cout
<<
endl;
f2.close();
}
posted on
2005-05-13 19:54
流云
阅读(
589
) 评论(
0
)
收藏
举报
刷新页面
返回顶部
博客园
© 2004-2025
浙公网安备 33010602011771号
浙ICP备2021040463号-3