Advertisement
Guest User

Untitled

a guest
May 25th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. void displayPets()
  2. {
  3.     string info;
  4.     int age;
  5.     ifstream fin;
  6.     fin.open("mypets.txt");
  7.     while (fin.good()) //.good() means while info is still running properly.
  8.     {
  9.     //I didnt add spaces in cout's for sake of demonstration.
  10.     fin >> info; //Name now stored in info
  11.     cout << info;
  12.     fin >> info; //breed now stored in info
  13.     cout << info;
  14.     fin >> age; // age now stored in age. Different data type, which we dont use info.
  15.     cout << age;
  16.     cout << endl; //end of line. The loop will continue on a new line, starting with a new pet.
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement