title: Read in from txt file into an array of structs of char arrays, help needed
body: <p>I've just recently taken C++ in my uni, and we have to make a phonebook program, which works with a txt file as input/output for the contacts.
  My problem is, that after restarting the program, (Ergo, flush the array of structures into the file and read it back in.) the structures are filled incorrectly. The name char array is left empty, the address takes the name-value, and the phone number array tries to take the address. I have to store first and last names in the name array, separated by a white space, as well as the full address into it's char array.</p>
  
  <pre><code>ifstream ifile;
  ifile.open("phonebook.txt");
  
  while(ifile.peek()!=EOF)
  {
      string temp;
      ifile&gt;&gt;b[a].id;
      getline(ifile, temp);
      for(int i = 0;i &lt; temp.length();i++)
          b[a].name[i] = temp[i];
      temp.clear();
      getline(ifile, temp);
      for(int g = 0;g &lt; temp.length();g++)
          b[a].address[g] = temp[g];
      temp.clear();
      ifile&gt;&gt;b[a].number;
      a++;
  }
  
  ifile.close();
  </code></pre>
  
  <p>Structure defined as:</p>
  
  <pre><code>struct derp
  {
      int id;
      char name[25];
      char address[25];
      char number[10];
  };
  
  derp b[100];
  </code></pre>
  
  <p>While I know using strings is better, and a whole lot easier, I'd like to do it with char arrays if possible.</p>
  
  <p>EDIT: 
  Text file is currently just a test/placeholder:</p>
  
  <pre><code>1
  Todor Penchev
  Sevlievo, BG
  0854342387
  </code></pre>