Stolar228

Untitled

Dec 14th, 2022
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. bool check_str_to_int(string str) {
  2.   for (int i = 0; i < str.length(); i++) {
  3.     if (!isdigit(str.at(i))) return false;
  4.   }
  5.  
  6.   return true;
  7. }
  8.  
  9. void table::imprt(string note) {
  10.     string shop, name, cost_str;
  11.     int cost;
  12.     ifstream in(note);
  13.     if (in.is_open()) {
  14.         while (!in.eof()) {
  15.             in >> shop;
  16.             in >> name;
  17.             in >> cost_str;
  18.             if (check_str_to_int(cost_str)) {
  19.               add(shop, name, stoi(cost_str));
  20.             } else {
  21.               cout << "Ошибка чтения (" << cost_str << ")" << endl;
  22.             }
  23.  
  24.         }
  25.         del(shop, name);
  26.     }
  27.     else {
  28.         cout << "File not Found: " << note << "\n";
  29.     }
  30.     in.close();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment