Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #163819
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Unix-y way to store records/structures within filesystem in C |
| Date | 2021-12-13 16:14 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <sp7ri3$aid$1@dont-email.me> (permalink) |
| References | <281cf765-1771-4549-9baf-9e2b8b886bb7n@googlegroups.com> |
Hello, Bithov Vinu On Sun, 12 Dec 2021 23:45:31 -0800, Bithov Vinu Student wrote: > Hi, > > I have data to store persistently with the following structure > (flashcard): > > - front - back - repetitions - ease factor - interval - next review [snip] > However, I've read the canonical Unix way of storing data with C is > different, using the filesystem. [snip] > Ideally my program would run on a per-user basis, ie. in the home > directory of a given user: > > ~/.cards/<WHERE THE CARDS ARE STORED> > > How would/should I store this data for efficiency and simplicity? Ideally, you should ask this question in the comp.unix.programmer newsgroup, as the answer depends more on the "Unix way of storing data" than it does on C. (While it has it's origins in Unix, modern C is a cross-platform language, which disguises and minimizes it's adherence to "the Unix way".) As for a C answer to your question, the best /I/ can do is "It depends". /Where/ you store the data depends on the best-practices of Unix and your installation. Offhand, I'd say that you are going in the right direction with your dotfile/dotdirectory solution. The /format/ of the data depends on how you intend to use the data, both inside your program and in the Unix environment at large. The canonical "Unix way" approach would be to have your program write and read your data as textual data (I won't go into /why/, here.) The /mechanism/ of your data manipulation, as far as comp.lang.c is concerned should be restricted to the fopen()/fread()/fscanf()/ fwrite()/fprintf()/fclose() family of APIs. The "Unix way" also includes many other POSIX APIs. It's your choice. If you care to discuss your project further, you'll find us on comp.unix.programmer HTH -- Lew Pitcher "In Skills, We Trust"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unix-y way to store records/structures within filesystem in C Bithov Vinu Student <vinub@calday.co.uk> - 2021-12-12 23:45 -0800 Re: Unix-y way to store records/structures within filesystem in C Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-12-13 16:14 +0000 Re: Unix-y way to store records/structures within filesystem in C songbird <songbird@anthive.com> - 2021-12-14 09:58 -0500
csiph-web