fork(3) download
  1. #include <thread>
  2. #include <string>
  3. #include <sstream>
  4. #include <chrono>
  5. #include <iostream>
  6. #include <vector>
  7. #include<algorithm>
  8.  
  9. using namespace std;
  10.  
  11.  
  12.  
  13. int main(int argc, char *argv[])
  14. {
  15. std::string s ;
  16. cin>>s;
  17. std::istringstream iss(s);
  18.  
  19. long num = 0;
  20.  
  21. if (!(iss >> num).fail()) {
  22. std::cout << num << std::endl;
  23. long myLong = std::stol(s);
  24. std::cout << myLong << std::endl;
  25. }
  26. else {
  27. std::cerr << "There was a problem converting the string to an integer!" << std::endl;
  28. }
  29. }
  30.  
  31.  
Success #stdin #stdout #stderr 0s 16064KB
stdin
as546546
stdout
Standard output is empty
stderr
There was a problem converting the string to an integer!