title: CSV file advanced parsing
body: <p>I have a problem with parsing a .csv file. I have a <code>struct world</code> defined like this:</p>
  
  <pre><code>typedef struct world
  {
      char worldName[30];
      int worldId;
      char *message;
      char **constellationArray;
      struct world *next;
  } tWorld;
  </code></pre>
  
  <p>And I have a .csv file designed like this (so the 'c' is for 'semi-Colon'):</p>
  
  <pre><code>worldId;worldName;message;constellationArray
  1;K'tau;Planeta pod ochranou Freyra;Aquarius;Crater;Orion;Sagittarius;Cetus;Gemini;Earth
  2;Martin's homeworld;Znicena;Aries;Sagittarius;Monoceros;Serpens;Caput;Scutum;Hydra;Earth
  3;...
  </code></pre>
  
  <p>The task seems simple: write a method <code>loadWorlds(char *file)</code>. Load the file and parse it. The number of constellations is not guaranteed. Each new line signals a new world and I have to create a linked list of these worlds. I have a rough idea of doing this, but I can't make it work. I have a method called <code>tWorld *createWorld()</code> which is implemented as such:</p>
  
  <pre><code>tWorld *createWorld() {
      tWorld *world;
      world = (*tWorld)malloc((sizeof(tWorld)));
      return world;
  }
  </code></pre>
  
  <p>I have to use this method inside my loadWorlds(char *file). Plus I have to serialize them into the linked list with this:</p>
  
  <pre><code>if (*lastWorld == NULL){
      *lastWorld = nextWorld;
  }else{
      (*actualWorld)-&gt;next = nextWorld;
  }
  *actualWorld = nextWorld;
  </code></pre>
  
  <p>But I don't know when to use it.  This is my rough sketch of <code>loadWorlds(char *file)</code>:</p>
  
  <pre><code>void loadWorlds(char *file)
  {
      FILE *f;
      char text[30];
      char letter;
      tWorld *lastWorld = NULL, *actualWorld = NULL, *world;
  
      //f = fopen(file, "r");
  
      if(!(f = fopen(file, "r")))
      {
          printf("File does not exist! \n");
          while(!kbhit());
      }
      else
      {
          while(!(feof(f)) &amp;&amp; (letter = fgetc(f))!= '\n')
          {
  
              if((znak = fgetc(f)) != ';')
              {
  
              }
  
          }
      }
  }
  </code></pre>
  
  <p>I would be grateful for any ideas to make this work.</p>