ppooi11i
路人甲
路人甲
  • 注册日期2009-04-05
  • 发帖数4
  • QQ
  • 铜币121枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1996回复:0

关于read函数 高手进

楼主#
更多 发布于:2009-06-12 01:07
<P>程序如下:</P>
<P>#include <iostream.h><BR>#include <fstream.h><BR>#include  <cmath><BR>void main()<BR>{<BR>  fstream f;<BR>  f.open("a.txt",ios::in);<BR>  if(!f){<BR>   cout<<"不能打开";<BR>   return;<BR>  }<BR>  fstream f2;<BR>  f2.open("b.txt",ios::out|ios::trunc);<BR>  if(!f2)<BR>  {<BR>  cout<<"不能创建 \n";<BR>  f.close();<BR>  return;<BR>  }<BR>  char ch;<BR> while(!f.eof()  ;; !f.fail() )<BR>  {<BR>    f.read(;ch,1);<BR> cout<<ch;<BR>    ch=char(int(ch));<BR> f2.write(;ch,1);<BR>  }<BR>  f.close();<BR>  f2.close();<BR>}</P>
<P>假如啊a.txt文件里的数据是12568 写到b.txt文件里的数据变为125688 问题出在循环的结束条件 请问如何修改</P>
喜欢0 评分0
游客

返回顶部