Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void displayPets()
- {
- string info;
- int age;
- ifstream fin;
- fin.open("mypets.txt");
- while (fin.good()) //.good() means while info is still running properly.
- {
- //I didnt add spaces in cout's for sake of demonstration.
- fin >> info; //Name now stored in info
- cout << info;
- fin >> info; //breed now stored in info
- cout << info;
- fin >> age; // age now stored in age. Different data type, which we dont use info.
- cout << age;
- cout << endl; //end of line. The loop will continue on a new line, starting with a new pet.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement