fork(6) download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. std::string line;
  10.  
  11. char c;
  12. while (std::getline(std::cin, line))
  13. {
  14. std::stringstream ss(line);
  15. ss >> c;
  16. if (! ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) ) ) {
  17.  
  18. // if it's not within bounds, then it's not a character
  19.  
  20. std::cout << "Error!" << std::endl;
  21.  
  22. // you can probably just return here as soon as you find a non-letter char,
  23. // but it's up to you to decide how you want to handle it exactly
  24. }
  25. else {
  26. std::cout << "its characters!" << std::endl;
  27. break;
  28. }
  29.  
  30. // std::cout << "Error! Insert only positive integers." << std::endl;
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 2864KB
stdin
65876
stdout
Error!