#include <iostream>
#include <fstream>
//#include <conio.h>
#include <cstdlib>
#include <string>
#include <sstream>
using namespace std;
int main()
{
char user_info= ' ';
string string_convert;
int num1;
bool bfail=true;
do
{
bfail=true;
cout << "Enter num1: ";
while(user_info != '\n')
{
cin.get(user_info);
if(isdigit(user_info))
string_convert+=user_info;
else if(user_info=='\n')
{
// user_info=='\n';
if(bfail==false)
string_convert="";
}
else
bfail=false;
}
user_info=' ';
}while(bfail!=true);
cerr << "before convert: " << string_convert << endl;
cout << "after convert: " << atoi(string_convert.c_str()) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KLy8jaW5jbHVkZSA8Y29uaW8uaD4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxzc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICBjaGFyIHVzZXJfaW5mbz0gJyAnOwogICAgc3RyaW5nIHN0cmluZ19jb252ZXJ0OwogICAgaW50IG51bTE7CiAgICBib29sIGJmYWlsPXRydWU7CgoKICAgIGRvCiAgICB7CiAgICAgICAgYmZhaWw9dHJ1ZTsKICAgICAgICBjb3V0IDw8ICJFbnRlciBudW0xOiAiOwogICAgICAgIHdoaWxlKHVzZXJfaW5mbyAhPSAnXG4nKQogICAgICAgIHsKICAgICAgICAgICAgY2luLmdldCh1c2VyX2luZm8pOwogICAgICAgICAgICBpZihpc2RpZ2l0KHVzZXJfaW5mbykpCiAgICAgICAgICAgICAgICBzdHJpbmdfY29udmVydCs9dXNlcl9pbmZvOwogICAgICAgICAgICBlbHNlIGlmKHVzZXJfaW5mbz09J1xuJykKICAgICAgICAgICAgewogICAgICAgICAgICAgLy8gICB1c2VyX2luZm89PSdcbic7CiAgICAgICAgICAgICAgICBpZihiZmFpbD09ZmFsc2UpCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nX2NvbnZlcnQ9IiI7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgYmZhaWw9ZmFsc2U7CiAgICAgICAgfQogICAgICAgIHVzZXJfaW5mbz0nICc7CiAgICB9d2hpbGUoYmZhaWwhPXRydWUpOwogICAgY2VyciA8PCAiYmVmb3JlIGNvbnZlcnQ6ICIgPDwgc3RyaW5nX2NvbnZlcnQgPDwgZW5kbDsKICAgIGNvdXQgPDwgImFmdGVyIGNvbnZlcnQ6ICIgPDwgYXRvaShzdHJpbmdfY29udmVydC5jX3N0cigpKSA8PCBlbmRsOwogICAgCgogICAgcmV0dXJuIDA7Cn0=