开发者

C (File Handling)

I have created a structure of patients' names in a hospital (in a file in .dat format)

The questions are: 1.So, when I want to delete the name of the patient already stored,how should I manage a code for that?

2.When I want to change the name of pat开发者_如何学JAVAient stored in the structure, how should I do that?


You'll probably need to:

  • Rewrite your full file (simpliest way), or:
  • Add blank to replace your deleted patient
  • If the new name is shorter, you can add blank between the end of the name and the next patient, or add blank to replace the patient and add the new name at the end of the file

The simpliest way is clearly to rewrite all the file, if it's not too important. Or you can maybe use something more adapted, like an SQLite database…


If you are managing data that needs to remain consistent, you should use a database. As already mentioned, SQLite is an offline database. It is a very powerful and easy to use library that treats a single file as a fully fledged SQL data source.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜