https://www.hackerrank.com/challenges/30-exceptions-string-to-integer/problem
Day 16 Exceptions - String to Integer Solution in Cpp
#include <iostream>
using namespace std;
int main(){
int64_t n;
string S;
cin >> S;
try {
n = stoi(S);
cout << n;
} catch (...) {
cout < "Bad String";
}
return 0;
}
0 Comments