title: Reading (variable length) input from a file in C
body: <p>I want to implement a function that reads data from a file. I can read data via fscanf, but the problem is that the length of the lines differ from line to line and I have to store them all. The file has the following format:</p>
  
  <pre><code>numberOfStates state1 state2 ... numberOfAlphabts alphabt1 ... transitiontable
  </code></pre>
  
  <p>What this means is that numberOfStates determines how many stateX will be after it. If its 5 then we have 0 1 2 3 4, if it was two then we would have 0 1, and its the same case with numberOfAlphabets. Lets say if it was 2 then we have a b after it; if it was 5 then we have a b c d e after it in that line. Also there is another problem: transitiontable is an array that stores all the combination of states and alphabets. For example if there were two states 0 1, and two alphabets a b then transtiontable would be:</p>
  
  <pre><code>a0 a1
  
  b0 b1 
  </code></pre>
  
  <p>Can anyone guide me on how to implement this? I have already implemented it, if the data was read from STDIN and not a file. But I can't get my head around on how to initialize transitiontable inside fscanf.</p>