?? subject_26443.htm
字號:
<p>
序號:26443 發表者:陳章民 發表日期:2003-01-01 11:06:11
<br>主題:如何讀入文字檔
<br>內容:如何讀入一個文字檔,然後依序將內容寫到一個陣列<BR>假如文字檔內容為<BR>10<BR>12<BR>14<BR>如何讀入陣列int array[3]<BR>使<BR>array[0]=10<BR>array[1]=12<BR>array[2]=14<BR>
<br><a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p>
<hr size=1>
<blockquote><p>
回復者:tjhe 回復日期:2003-01-01 11:45:43
<br>內容:CStdioFile f("your file name");<BR>CString str;<BR>int i=0;<BR>while(f.ReadString(str))<BR>{<BR> array[i] = atoi(str);<BR> i++;<BR>}
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回復者:upstream 回復日期:2003-01-01 12:46:27
<br>內容:樓上的朋友的辦法很好,不過個人認為CFile,CStdFile類只適合<BR>讀取二進制和純文本文件,對于讀取這樣全是數字的文本文件,<BR>還是用C++的流文件讀取最方便。<BR><BR>#include "fstream.h"<BR><BR>int i=0;<BR><BR>fstream file;<BR>file.open("input.dat",ios::in);<BR>while(!file.eof())<BR>{<BR> file>>array[i];<BR> i++;<BR>}<BR>file.close();<BR><BR>
<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 + -