Re: [問題] FileHeader 的結構???

看板PttCurrent作者 ( )時間16年前 (2008/08/25 22:53), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《VElysian (家瑀 致中和)》之銘言: : 下面是我從 https://opensvn.csie.org/pttbbs/trunk/ 找到的 FileHeader : 並且計算其長度如下: : #define IDLEN 12 /* Length of bid/uid */ : #define TTLEN 64 /* Length of title */ : #define FNLEN 28 /* Length of filename */ : typedef struct fileheader_t : { /* 128 bytes */ : ─────────────────────────────────────── : 型態 名稱 長度 解釋 : ─────────────────────────────────────── : 01 char filename[FNLEN] 28 ( 1~ 28) : 02 time4_t modified 2 ( 29~ 30) 最後修改時間 (1970/1/1 起秒數) 4 ( 29~ 32) : 03 char pad 1 ( 31~ 31) 未使用 ( 33~ 33) : 04 char recommend 1 ( 32~ 32) 推薦數 ( 34~ 34) : 05 char owner[IDLEN + 2] 14 ( 33~ 46) 發文者 ( 35~ 48) : 06 char date[6] 6 ( 47~ 52) 發文日期字串 ( 49~ 54) : 07 char title[TTLEN + 1] 65 ( 53~117) 文章標題 ( 55~119) : 08 char pad2 1 (118~118) 未使用 (120~120) : 09 union multi 8 (119~126) 文章價值/其它資料 4 (121~124) : 10 unsigned char filemode 1 (127~127) 文章屬性 (FILE_*) (125~125) : 11 char pad3[3] 1 (128~128) 未使用 3 (126~128) : ─────────────────────────────────────── : } PACKSTRUCT fileheader_t : ─────────────────────────────────────── : 有一個地方我覺得怪怪的, : 我對照了一下信件備份中的 .DIR 檔,發現作者的欄位好像是從位置 35 開始的... : 請問為甚麼會這樣呢?? 是我算錯了嗎??? : 另外再問一下上面每一個變數的功用以及應該要如何讀取。 謝謝。 ^_^ FILE* fp = fopen(".DIR", "rb"); fileheader_t fh; while(fread(&fh, sizeof(fh), 1, fp) == 1){ printf("Post %s from %s in file %s\n", fh.title, fh.owner, fh.fileename); } -- All this will not be finished in the first 100 days. Nor will it be finished in the first 1,000 days, nor in the life of this Administration, nor even perhaps in our lifetime on this planet. But let us begin. -- John F. Kennedy, Inaugural Address -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.30.54 ※ 編輯: scwg 來自: 140.112.30.54 (08/25 22:59)
文章代碼(AID): #18iiTL-5 (PttCurrent)
文章代碼(AID): #18iiTL-5 (PttCurrent)