#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>

using namespace std;

int main() {
	const char* foo[] = { "12", "1X", "X2" };

	for (auto& i : foo) {
		int temp = atoi(i);

		(temp == 0) ? cout << "atoi: check string(0)\n" : cout << "atoi: " << temp << endl;

		(istringstream(i) >> temp) ? cout << "istringstream::operator>>: " <<  temp << endl : cout << "istringstream::operator>>: error flag(0)\n";

		try {
			cout << "stoi: " << stoi(i) << endl;
		} catch(const invalid_argument& e) {
			cout << "stoi: threw " << e.what() << endl;
		}
	}
	return 0;
}