title: Reading integers from a text file in C line by line and storing them in an array
body: <p>I am new to C and have been trying to do this for a while now.</p>
  
  <p>I need to read the integer values from a text file that has :</p>
  
  <p>G = 10</p>
  
  <p>P = 5</p>
  
  <p>Gayle: 1,2,3,4</p>
  
  <p>Price: 4,3,5,6.6</p>
  
  <p>Need to pick out the Gayle and Price values and store them in 2 seperate arrays and store the G and P values in 2 separate variables.</p>
  
  <p>So far I have done :</p>
  
  <pre><code>FILE* file = fopen(abc.txt, "r");
  //for gayle values
  int g_array[100];
  int i=0;
  int gayle_val;
  while(fscanf("%d", &amp;gayle_val)==1)
  {
      g_array[i]=gayle_val;
  }
  //for price values
  int p_array[100];
  int i=0;
  int price_val;
  while(fscanf("%d", &amp;price_val)==1)
  {
      p_array[i]=price_val;
  }
  //for G and P values
  </code></pre>
  
  <p>How do I combine the searches for the 4 lines such that the read is done line by line and values stored accordingly ?</p>
  
  <p>Thank you so much in advance !</p>