title: saving word by word ,from each line , from a file in c
body: <p>Suppose we have some contacts in a file, like a small phone book.</p>
  
  <p>I want to make a small programme that works like an online phone book each contact in the text takes the size of a <code>Line</code> and, the order that the Information is placed looks like this : <code>NAME SURNAME ADRESS PHONE</code>,
  but the Number of phones that each contact has can be more then one.
  so for example :</p>
  
  <pre><code> George Mikels "green str" 123123 12121232 
   Maria Luis "olive str" 6548845
  </code></pre>
  
  <p>In my attempt I have done this so far: </p>
  
  <pre><code>void Createtree(node **head_node)
  {
      int count=0,*phones;
      char filename[50], name[30], surname[50], adress[70];
      char c;
  
      FILE *fp;
      printf("PLease enter the name of the file\n");
      scanf("%s", &amp;filename);
  
      fp = fopen("text.txt", "r");
      if(fp == NULL)
      {
          printf("failed to open file");
          return ;
      }
  
      do
      {
          c=fscanf(fp, "%s %s %s ", &amp;name, &amp;surname, &amp;adress);
  
          //takes the name ,surname and adress
          printf(" %s %s %s\n", &amp;name, &amp;surname, &amp;adress);
          phones = (int*)malloc(sizeof(int));
  
          //creates a dynamic array of int in order to save the phones
          do
          {
              //saves each Number inside the array
              c = fscanf(fp, " %d ", phones[count]);
              count = count + 1;
  
              phones = (int*)realloc(phones, (count +1) * sizeof(int));
  
              // increases the size of the array in order to save all the phones 
          }while(c != '\n');
  
          //does it until the end of the Line 
          count=0;
  
          Insert(head_node,name,surname,phones);
          //uses a function to add the Information to a list 
  
      }while(c != EOF);
  };
  </code></pre>
  
  <p>I can't save the phones inside the array and I don't know why.</p>