Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int countPerson(std::fstream& file) { //tutaj metoda z klasy
- int sum = 0;
- std::string line;
- while(std::getline(file, line)) {
- std::string name;
- int age;
- std::stringstream ss(line);
- ss >> name;
- ss >> age;
- std::cout << "Imię: " << name << std::endl;
- std::cout << "Wiek: " << age << std::endl;
- sum++;
- }
- return sum/2;
- }
- };
- bool openFile(const char* path, std::fstream& fileClass) {
- fileClass.open(path, std::ios::app | std::ios::in);
- return fileClass.is_open();
- }
- int main() {
- setlocale(LC_ALL, "PL_pl");
- std::fstream newFile;
- if (openFile("osoby", newFile)) {
- Person JP2;
- JP2.getPersonalities();
- JP2.saveToFile(newFile);
- std::cout << JP2.countPerson(newFile) << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement