title: How Do I Store and Retrieve a Struct into a Shared Memory Area in C
body: <p>For a uni assignment I need to create a circular list of up to 10 file names, and then store these in a shared memory area, so that 2 child processes can read/write to the list (using a semaphore to control access).  Trouble is, that I am a total C novice and I feel loss and despair because its totally out of my depth.  I need some help in "filling in the holes" of my knowledge.</p>
  
  <p>Right now, I am simply focussing on it one problem at a time, and presently, I am only trying to get my circular list into the shared memory area.</p>
  
  <p>So far I have:</p>
  
  <pre><code>typedef struct FILE
  {
     struct FILE *f_link;  /* forward link for linked list */
     char name[255];       /* name of the file */
  
  } FILE_entry;
  </code></pre>
  
  <p>As my struct which will hold the reference to the file that comes next (f_link). this way I can just call ->f_link to get the next item in the list, and where the 10th element will simply have its f_link directed back to the 1st.  My reason for doing this is so that I can simply traverse the list without an iterator (and never have to check for the end of the list as I would with an array).</p>
  
  <p>I also know that I need to use <code>shmget</code> to get the memory area, and I understand it, I pass <code>shmget</code> a key, a size and a flag (which i dont get) and it returns an identifier in the type of an int.</p>
  
  <p>So my question is 2 fold.  How do I store my linked list INTO the shared memory area - and how do I access it FROM the shared memory area?</p>