I want my program to throw exception on console window. But when exception occures Microsoft Visual C++ Runtime library dialog box shows up.
What can I do to stop visual studio from stopping execution of my program when an exception occues and let my program handle the exception?
I am using Visual Studio 2012 and with the following code.
#include<iostream>
#include<vector>
#include <stdexcept>
using namespace std;
int main()
try {
vector<int> v;
int data;
while(cin >> data) v.push_back(data);
for(unsigned int i = 0; i<=v.size(); i++) cout << v[i] << endl;
return 0;
}
catch(out_of_range){
cout << "Data fetch out of bound" << endl;
return 1;
}
catch(...){
cout << "Something went wrong!" << endl;
return 2;
}