title: simple database text file in c++
body: <p>i want to make a database of animals that save the data after i close the program. So i thought it should be saved in a text file.</p>
  
  <p>1) Is there an already made c++ function for that?</p>
  
  <p>2) in case not, how can we solve the problem?</p>
  
  <p>Until now, i have this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  class Animal {
    public: 
      std::string name, color1, color2, race, notes;
      int age;
  };
  
  void writeInTheDatabase(Animal const&amp; ani);
  int readAgeFromTheDataBase(Animal const&amp; ani);
  
  int main() {
  
      Animal cat1;
      cat1.name = "silvester";
      cat1.color1 = "black";
      cat1.color2 = "white";
      cat1.age = 4;
  
      Animal dog1;
      dog1.name = "Arnold";
      dog1.color1 = "brown";
      dog1.color2 = "black";
      dog1.age = 3;
  
      writeInTheDatabase(dog1);
      std::cout &lt;&lt; "the age is: " &lt;&lt; readAgeFromTheDataBase(dog1) &lt;&lt; std::endl;
  }
  
  void writeInTheDatabaseTextFile(Animal const&amp; ani) {
      // this function  should put all the info in a text file   
  }
  
  int readAgeFromTheDataBase(Animal const&amp; ani) {
      int age;
      // this function should return the age of an animal given
      return age;
  }
  </code></pre>