Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <utility>
- #include <string>
- #include <fstream>
- using namespace std;
- int main()
- {
- vector <int> a;
- vector <string> v;
- string path = "noice.txt";
- ifstream fin;
- fin.open(path);
- if (!fin.is_open())
- {
- cout << "error" << endl;
- }
- else
- {
- string str;
- while (!fin.eof())
- {
- getline(fin, str);
- v.push_back(str);
- }
- }
- fin.close();
- for (int i = 0; i < (int)v.size() - 1; i++)
- {
- try {
- int res = stoi(v[i]);
- a.push_back(res);
- }
- catch (std::invalid_argument e) {
- cout << "caught invalid argument exception\n";
- cout << i;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement