讀取Hex檔案並求和

2021-09-17 07:15:09 字數 895 閱讀 9745

1.讀取hex檔案

void ctestprojectdlg::onbnclickedbuttonreadhex()

cfile m_file;

m_file.open(filename, cfile::modenotruncate | cfile::modecreate | cfile::moderead);

int nlen = (int)m_file.getlength();//檔案的長度

unsigned char *m_bigdatabuf;

m_bigdatabuf = (unsigned char*)malloc(nlen);

m_file.seektobegin();

m_file.read(m_bigdatabuf, nlen);

m_file.close();

yangsen.clear();

uint ntotalsum = inchecksum8(m_bigdatabuf, nlen);

uint ntotalsum = inchecksum8(m_bigdatabuf, nlen-2);//就代表最後兩個數不加

}

還有求和函式

uint ctestprojectdlg::inchecksum8(unsigned char* addr, int len)

//計算從後往前累加,看累加到哪個值之後總和的後2個位元組值等於42759

// addr += len-1;

// while (len > 0)

//

// addr -= 1;

// len -= 1;

// }

return sum;

}

讀取配置檔案並讀取檔案

配置檔案 url users z ten documents name myfile.txt url是讀寫檔案的檔案位址,name是讀寫檔案的檔名稱 fileinputstream is null try catch filenotfoundexception e2 properties pt ne...

開啟並讀取檔案

開啟並讀取檔案 file open r c users administrator desktop walden.txt r lines file.readlines words for line in lines tmp list line.split for word in tmp list 對...

PCD檔案讀取並顯示

前面一段時間一直在寫 好久都沒有進行程式設計學習,突然覺得無從下手了,翻開以前寫的 練練手,順便記錄下來以便以後自己可以快速熟悉。乙個簡單的點雲pcd檔案讀取,並視覺化。filename pcd read date 2018 3 27 description read pcd files point...