C 共享内存数据库

发布于 2024-09-30 09:23:00 字数 385 浏览 0 评论 0原文

所以这是一项家庭作业,有点奇怪,所以我会尝试长话短说。基本上我正在制作一个包含 5 个文件的共享内存数据库(加载、查询、清理、打印、更改) Load 从文件加载数据库。 (学生有名字/姓氏/地址/电话号码) 查询让某人“搜索”特定学生 print....打印共享内存的内容 改变让人们改变数据库 clean 会删除分隔符并将共享内存的内容保存到文件中。

现在教授给了我们一堆代码,大部分我都理解了。他的文件被分成 3 个文件。 (更改、创建和头文件) 我的主要问题是,我将如何将多个“对象”存储到共享内存中。

就像他自然地将学生数据保存在结构中一样,对于他的“示例”,他似乎通过使用 struct * ptr 来加载它。但我该如何加载多个学生呢?

我可以在这里发布源代码,但它有 4 个不同的文件,而且很长。

So this is a homework assignment, and it's kind of a doozy so i'll try to TL;DR it. Basically Im making a Shared memory database with 5 files (load,query,clean,print,change)
Load loads the database from a file. (students have a first name/last name/address/telephone number)
Query lets someone "search" for a specific student
print....well prints the contents of the shared memory
and change lets people change the database
and clean gets rid of the sephamores and saves the contents of the shared memory to a file.

Now the professor gave us a bunch of code, and for the most part I understand it. His was seperated in 3 files. (a change,create and header file)
My main question is, how would I go about storing multiple "objects" into shared memory.

Like he keeps the student data in a struct naturally, and for his "example" he seems to load it by using a struct * ptr. But how would I go about loading multiple students?

I could post the source here, but it's 4 different files and quite long.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

注定孤独终老 2024-10-07 09:23:00

使用结构数组而不是单个结构?

Use an array of structs, instead of a single struct?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文