PLEASE NOTE: the upgrades to this server, secure.csse.uwa.edu.au, have not yet been completed.
Hopefully the changes will be completed on THURSDAY 8th December.
Web-based programs, such as csmarks, cssubmit, and the help fora, will be unavailable at some time on Thursday 8th.
  It's UWAweek 49

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

Displaying the 3 articles in this topic
Showing 3 of 919 articles.
Currently 4 other people reading this forum.


 UWA week 40 (2nd semester, week 10) ↓
SVG not supported

Login to reply

👍?
helpful
12:30pm Wed 5th Oct, Zhuo H.

Hi Professor, I am trying to store my data in the trove file, Which is a combination of some struct looks similar to this (Not the same in my work, just for demo) typedef HASH_FILE *filelist; typedef struct filelist { char *string; HASH_WORD *keys; struct filelist *next; } FILELIST; typedef HASH_WORD *wordlist; typedef struct wordlist { char *string; struct wordlist *next; } as you can see, HASH_FILE is a hash table to store all the file's info, and HASH_WORD is to stores the "words" in that file. but you can also tell if I want to store this into the trove file, there are a loooot of pointers (or I should say they are practically all pointers) and I'm stuck on how to store pointers, not to mention how to store so many pointers inside another pointer. I tried to google this question, but it is not much help. Can you give me some hints on how to achieve it or is there any article that will help? Or I should give up on this and just stick with text file r/w instead?


SVG not supported

Login to reply

👍?
helpful
12:35pm Wed 5th Oct, Zhuo H.

for the last sentence, I mean should I change all the pointers into arrays so they can be stored in a text file? I know how to r/w to a text file, but not very familiar with working with a binary file in this situation.


SVG not supported

Login to reply

👍?
helpful
3:59pm Wed 5th Oct, Christopher M.

"Zhuo Hu" <23*0*3*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> and I'm stuck on how to store pointers, not to mention how to store so many pointers inside another pointer. I tried to google this question, but it is not much help.
It's possible (easy) to store the value of a pointer in a file - printf("%p\n", (void *)my_pointer ); BUT, you should re-think your approach. The value of a pointer is meaningful in a process that allocated/created it but, if written to a file, the pointer is extremely unlikely to have a correct meaning in another process reading it back in. The address space of each process, and the addresses where things are stored in one process are almost guaranteed to be different in another process. Even the same program, run twice, will 'get' different addresses. See - https://en.wikipedia.org/wiki/Address_space_layout_randomization Rethink your approach to avoid storing pointers/addresses in the trove-file.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy