在swf_file_format_spec_v10.pdf中,對舞台大小是用一種rect結構體來表示,根據官方文件的描述,這種結構體是這樣的
//讀取rect型別
/*目前想到的方案:
* 1.將這九個位元組資料轉化成字元竄,然後通過擷取字元竄得到所要的資料,
* 最後轉化成整數
* 2.乙個位元組乙個位元組的擷取所需要的資料,然後通過乙個整數變數來將其構造而成
* */
#include int getubytes(const unsigned char *data, int start, int length);
int checksignbit(int num, int bit_n)
return num;
}int readrect(const unsigned char* filebuffer) else
return 0;
}//這個是取第二種方案。
//根據所需要的位元數得到資料,該資料為無符號整形uint
int getubytes(const unsigned char *data, int start, int length)
//length占用位元組數後剩餘的位數
last_part = (length - first_part) % 8;
//data所佔的位元組數
length_b = (length - first_part) / 8;
//最後一位的構造
value = data[move + length_b + 1] >> (8 - last_part);
//中間幾位的構造
i = 0;
while (length_b)
//第一位的構造
value = value | ((data[move] & (mask >> (8 - first_part)))<< (last_part + i * 8));
return value;
}int main(int argc, char *argv)
結構體儲存檔案,從檔案中讀取結構體
include include include typedef enumtype typedef structcard int fd 0 initialize card void init card card open a file int file open void return 0 read ...
結構體中巢狀結構體
結構體的巢狀問題 結構體的自引用 self reference 就是在結構體內部,包含指向自身型別結構體的指標。結構體的相互引用 mutual reference 就是說在多個結構體中,都包含指向其他結構體的指標。1.1不使用typedef時 錯誤的方式 struct tag 1 這種宣告是錯誤的,...
結構體指標中包含結構體指標
將c 轉化為c的過程中,一些c 的特性無法使用 類內私有變數在類內公共函式中使用,轉化為c的時候選擇用malloc的方式,申請一段記憶體空間去儲存它,在函式中傳指標形參去操作這些變數。這時候遇到乙個問題,結構體中包含了另乙個結構體的指標,這導致了我malloc的時候,另乙個結構體中的記憶體空間沒有申...