25.11.2014 Views

o_197jmc471vk31iah1ofmlto10toa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

附 錄 : 如 讀 取 .txt 檔 案<br />

void COpen_FileDlg::OnBnClickedOk()<br />

{<br />

// TODO: Add your control notification handler code here<br />

FILE *fptr;<br />

char str[300];<br />

fptr = fopen("\data.txt","r");<br />

//(1) 檔 名 , (2) 開 文 件 方 式 為 只 讀 , 文 件 指 針 指 到 開 始 處<br />

if(fptr==NULL)<br />

{<br />

exit(0);<br />

}<br />

while(fgets(str,300,fptr)) //(1) 存 放 位 置 , (2) 抓 取 長 度 , (3) 開 檔 變 數<br />

{<br />

CString er;<br />

er.Format(L"%S",str);<br />

this->m_temp.AddString(er);<br />

}<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!