[操作疑難] 學 C program project 一問

本帖最後由 samtsui333 於 2014-10-29 19:13 編輯

----DONE----

Any ching help me

TOP

你知道一個 record 有幾大, 理應知道一個 record 的 file 有幾大.
咁由 file size 就應該知道有幾多 record 呱?

我純粹段估.... C 我只係識 d 唔識 d.

TOP

1) why you need to limit the records?
2) when you open the file, read the file to count the number of records and stored it in a counter. (since max is 100 records, should not have much perforamnce issue)... and with each addition/deletion of staff records you will update the counter, so you know the current number of records

TOP

回覆 4# look_yau


  1) as it is the project requirement ar!
2) the change and the deletion cannot count the record,  as they only scan(lookup) the first found record for the process. I cannot figure out how to count the number of records.......

TOP

project requirement有冇限個txt唔可以放staff record以外既野先
冇既你放個count去txt最頭, 每做一次add/delete先scan返個count
add/delete之後update返個count
你可以當count係一個staff entry, name唔係人名就得, 我當你叫做Counting
AGE就係個number of records, basic salary你入乜都得啦
display加返 staff name == Counting 就唔show呢個record
IDEA大概係咁, coding你自己諗返
唔好怪我多事, 你個program有少少know too much...

TOP

回覆  look_yau


  1) as it is the project requirement ar!
2) the change and the deletion  ...
samtsui333 發表於 2014-10-29 13:02


just read the whole file in the beginning and you can count the number of recrods

TOP

1. 應該把 options 1- 4 寫成 subroutines

2.  既然 random access, 不必每次 delete 就 rewrite 整個 file 一次! 可以在讀入 record-to-be-deleted 後, set name[0] = 0, 再寫回原來位置; 以後 read record 時, 碰上這些 recoeds 就 skip to next record 即可

3. 6 樓的想法可行, 但用dummy record 做 counter 有點混淆, 直接使用 integer counter 好了

TOP

回覆 3# IanW
回覆 6# yjfoeg
回覆 7# look_yau
回覆 8# skhui2005


    DONE! THX CHINGS!

TOP