title: Unable to take input from a file containing string variables
body: <p>I decided to make a phonebook in c++ and decided to take input of names, address and number from a file.
  So I made a class called contact and declared the  public variables name, address and number.
  Using a constructor I initialized these to name="noname"(string), number=0(int), address="no address"(string)
  Now my body of main goes as:</p>
  
  <pre><code>int main(){
  
  contact *d;
  
  d= new contact[200];
  
  string name,add;
  
  int choice,modchoice;//Variable for switch statement
  
  int phno,phno1;
  
  int i=0;
  int initsize=0, i1=0;//i is declared as a static int variable
  
  bool flag=false,flag_no_blank=false;
  
  
  //TAKE DATA FROM FILES.....
  //We create 3 files names, phone numbers, Address and then abstract the data from these files first!
  
  fstream f1;
  fstream f2;
  fstream f3;
  
  string file_input_name; 
  string file_input_address;
  
  int file_input_number;
  
  
  f1.open("./names");
  
  while(f1&gt;&gt;file_input_name){
  
    d[i].name=file_input_name;
  
    i++;
  
  }
  initsize=i;
  
  
  f2.open("./numbers");
  
  while(f2&gt;&gt;file_input_name){
  
    d[i1].phonenumber=file_input_number;
    i1++;
  
  }
  
  
  f3.open("./address");
  
  while(f3&gt;&gt;file_input_address){
  
    d[i1].address=file_input_address;
  
    i1++;
  
  }
  </code></pre>
  
  <p>now when I later search for a particular entry by name, the name is displayed correctly but the phoneumber is returned as a garbage value and address as "Noaddress"
  I dont understand why this is happening...
  In case u want to look at entire code, do let me know....</p>
  
  <p>This is how i search for a particular entry which returns the name if matched but returns garbage for phone number....</p>
  
  <pre><code>cout&lt;&lt;"\nEnter the name";//Here it is assumed that no two contacts can have same contact number or address but may have the same name.
  cin&gt;&gt;name;
  
  int k=0,val;
  cout&lt;&lt;"\n\nSearching.........\n\n";
  
  for(int j=0;j&lt;=i;j++){
    if(d[j].name==name){
      k++;            
      cout&lt;&lt;k
          &lt;&lt;".\t"
          &lt;&lt;d[j].name
          &lt;&lt;"\t"&lt;&lt;d[j].phonenumber
          &lt;&lt;"\t"&lt;&lt;d[j].address
          &lt;&lt;"\n\n";
      val=j;                  
    }
  }
  </code></pre>
  
  <p>Thanks in advance </p>