Error reading result file.You should use exception handling concepts.

1 Antwort [Letzter Beitrag]
Mr_Robot
Offline
Beigetreten: 08/15/2015

```
#include
#include
#include
#include
#include

using namespace std;

int main(){
string s;
int n;

getline(cin,s); // read a string
try{
// bitset constructor throws an invalid_argument if initialized
// with a string containing characters other than 0 and 1
//bitset<5> mybitset (string("[a-z0-9]{0,6}"));
// convert to string to int
n = stoi(s);
cout << n;

}
// if s cannot be converted to an integer, print Bad String
catch(invalid_argument& ia){
cerr << "Bad String" << ia.what() << endl;
return 1;
}

return 0;
}

```

What's my problem?

I don't understand.

Magic Banana

I am a member!

I am a translator!

Offline
Beigetreten: 07/24/2010