Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void open_from_file()
- {
- ifstream file;
- string buff;
- file.open("save_file.csv", ios::in);
- n = 0;
- file >> buff;
- if (!file.is_open()){
- cout << "(!) File doesn't exist!\nCreate it? [Y/N]\n" << endl;
- cout << "~ ";
- string create_file; cin >> create_file;
- if (create_file == "Y"||create_file == "y"
- ||create_file == "ะ"||create_file == "ะด")
- { ofstream file;
- file.open("save_file.csv", ios::out);
- cout << "(!) File created!" << endl;}
- else cout << "Creating aborted..." << endl;
- file.close();
- }
- else {
- if (buff.empty())
- cout << "(!) File is empty..." << endl;
- else {
- ifstream file;
- file.open("save_file.csv", ios::in);
- while (!file.eof())
- {
- std::getline(file, Hotel[n].id, ';');
- std::getline(file, Hotel[n].date_1, ';');
- std::getline(file, Hotel[n].date_2, ';');
- std::getline(file, Hotel[n].name, ';');
- std::getline(file, Hotel[n].second_name, ';');
- /*ostringstream temp;
- temp << Hotel[n].money;
- string cost = temp.str(); (int to str)
- std::getline(file, cost, ',');*/
- std::getline(file, Hotel[n].money, ';');
- std::getline(file, Hotel[n].number_phone, ';');
- n++;
- }
- cout << "\n\t(!) Reading successfully! Objects: " << n <<".\n\t\tOpened: save_file.csv" << endl;
- }
- }
- file.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement