📄 subject_39802.htm
字号:
<p>
序号:39802 发表者:Chuicy 发表日期:2003-05-13 20:57:05
<br>主题:fread and fwrite
<br>内容:It should be very simple, but I really can't find the problem.so for help:<BR><BR> FILE *fp1;<BR> FILE *fp2;<BR> fp1=fopen("text_transmit.txt","rb");<BR> fp2=fopen("text_receive.txt","wb");<BR> int i=0;<BR> while((getc(fp1))!=EOF) <BR> i++;<BR> int nr_size_short=i;<BR> char *a=new char[nr_size_short];<BR> fread(a,sizeof(char),nr_size_short,fp1); <BR><BR> //when comes to this,the value is a is totally wrong, just -51 'f',?//<BR><BR> fclose(fp1);<BR> fwrite(a,sizeof(char),nr_size_short,fp2);<BR> fclose(fp2);<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:dr0 回复日期:2003-05-13 21:27:50
<br>内容:fread(a,sizeof(char),nr_size_short,fp1); <BR>// when your codes comes here, the FILE pointer is now pointing to the<BR>// nr_size_short + 1, so when you call the fread() , it will read from<BR>// the nr_size_short + 1. you can reset the FILE pointer to the begining<BR>// use fseek(fp1, 0, 0). have a try ?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -