title: How to read different types of data from file
body: <p>I have a text file that contains string, int and double. Like this:</p>
  
  <blockquote>
    <p>Asher 10 14.5</p>
    
    <p>Julia  14 15.5</p>
  </blockquote>
  
  <p>I need to read this data to 3 separate arrays. C don't have string array, so I need char array, int array and double array. My code:</p>
  
  <pre><code>const int num = 18; //number of data.txt lines
  char col_one[15];
  int col_two;
  double col_three;
  int c;
  int numberArray[num];
  char *nameArray[num];
  double doubleArray[num];
  int size = 0;
  FILE *file;
  file = fopen("data.txt", "r");
  if (file) {
      while ((c = getc(file)) != EOF)
      {
          fscanf(file, "%s %d %lf", &amp;col_one, &amp;col_two, &amp;col_three);
          nameArray[size] = col_one;
          numberArray[size] = col_two;
          doubleArray[size] = col_three;
          size++;
      }
      fclose(file);
  }
  
  
  for (int i = 0; i &lt; num; i++)
  {
      printf("%s \n" ,nameArray[i]);
  }
  </code></pre>
  
  <p>But my code reads only first word and print it 18 times. How can I read string variable and put it into char array?</p>