// mypro1dlg.cpp : 實現檔案//
#include "stdafx.h"
#include "mypro1.h"
#include "mypro1dlg.h"
#include "afxdialogex.h"
#ifdef _debug
#define new debug_new
#endif
// 用於應用程式「關於」選單項的 caboutdlg 對話方塊
class caboutdlg : public cdialogex;
protected:
virtual void dodataexchange(cdataexchange* pdx); // ddx/ddv 支援
// 實現
protected:
declare_message_map()};
caboutdlg::caboutdlg() : cdialogex(caboutdlg::idd)
void caboutdlg::dodataexchange(cdataexchange* pdx)
begin_message_map(caboutdlg, cdialogex)
end_message_map()
// cmypro1dlg 對話方塊
void cmypro1dlg::dodataexchange(cdataexchange* pdx)
begin_message_map(cmypro1dlg, cdialogex)
on_wm_syscommand()
on_wm_paint()
on_wm_querydragicon()
on_bn_clicked(idc_btnreadfile, &cmypro1dlg::onbnclickedbtnreadfile)
on_bn_clicked(idc_btnwritefile, &cmypro1dlg::onbnclickedbtnwritefile)
// on_wm_create()
end_message_map()
// cmypro1dlg 訊息處理程式
bool cmypro1dlg::oninitdialog()
void cmypro1dlg::onsyscommand(uint nid, lparam lparam)
else}
// 如果向對話方塊新增最小化按鈕,則需要下面的**
// 來繪製該圖示。對於使用文件/檢視模型的 mfc 應用程式,
// 這將由框架自動完成。
void cmypro1dlg::onpaint()
else}
//當使用者拖動最小化視窗時系統呼叫此函式取得游標
//顯示。
hcursor cmypro1dlg::onquerydragicon()
void cmypro1dlg::onbnclickedbtnreadfile()
cfile file;//(m_filename,cfile::moderead) 錯誤1;
if(file.open(m_filename,cfile::moderead,null)==null)
filelength=file.getlength();
byte *pbuf;
pbuf=new byte[filelength+1];
b_out=new short[filelength+1];//錯誤2:不能把b_out,c_out宣告為char型,否則後面的資料轉換會有問題;
c_out=new short[filelength+1];//char只有乙個位元組,而int為四個位元組(大小轉換問題)
memset(b_out,0,filelength+1);//初始化陣列
memset(c_out,0,filelength+1);
pbuf[filelength]=0;
t_length=int((filelength-1024))/512;//計算資料讀取時間
if(!m_progress.m_hwnd)
else
m_progress.movewindow(crect(0,0,200,30));
progressnumber=0;
file.seek(1024,file.begin);//錯誤3:不能把這句話寫在for迴圈內部,否則每次迴圈都在檔案資料起始點開始
for(int i=0;i
file.read(pbuf,512);
//心電資料
for(int j=0;j<250;j++)
else
b_out[j+i*250]=b_upper*16+b_low; }
//呼吸資料
for(int j=0;j<25;j++)
else
c_out[j+250*i]=c_upper*16+c_low;
}
}file.close();
progressnumber=0;//一定要清零,否則在下面進行檔案寫入時會出現問題,
//double(progressnumber)/double(t_length)的比值大於1,導致m_pos>100}
void cmypro1dlg::onbnclickedbtnwritefile()
else
m_progress.movewindow(crect(0,0,200,30));//錯誤4:當時誤將crect的兩個y值弄成一樣的了
//寫入心電資料
for(int j=0;j
這個程式出現的問題在**中都一一表明,關於char和int的型別轉化問題,關於檔案指標的位置,這兩個問題除錯了一晚上,在陳師兄幫助下解決了,還有乙個是關於cfile file()已經初始化,另外在file.open中設定了一遍,導致程式的失敗。還有就是關於變數的清零,還有因為粗心導致的問題。
C 讀取excel檔案資料丟失問題
當使用oledbdataadapter.fill填充資料到datatable時,資料行與excel行數不一致 修改oledbconnection配置連線字串 修改前 修改後 imex是用來告訴驅動程式使用excel檔案的模式,其值有0 1 2三種,分別代表匯出 匯入 混合模式。當我們設定imex 1...
Swift plist檔案資料的讀取和儲存
2015 09 28 09 37 發布 hangge 每次在xcode中新建乙個ios專案後,都會自己產生乙個.plist檔案,裡面記錄專案的一些配置資訊。我們也可以自己建立.plist檔案來進行資料的儲存和讀取。plist檔案其實就是乙個xml格式的檔案,其支援的資料型別有 ns省略 dictio...
matlab讀取csv檔案資料
注意 csvread函式只試用與用逗號分隔的純數字檔案 第一種 m csvread filename 直接讀取csv檔案的資料,並返回給m 第二種 m csvread filename r,c 讀取csv檔案中從第r 1行,第c 1列的資料開始的資料,這對帶有標頭檔案說明的csv檔案 如示波器等採集...