Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. void AccountData::assignAccount()
  2. {
  3. std::cout << "Input Account Name: ";
  4. std::string inputAccount;
  5. std::getline(std::cin, inputAccount);
  6. std::string useAccount = inputAccount.substr(0, 15);
  7.  
  8. if (std::all_of(begin(useAccount), end(useAccount), std::isalnum)) varAccount = useAccount;
  9. else
  10. {
  11. bool valid = true;
  12.  
  13. while (valid)
  14. {
  15. std::cout << "nAccounts can only contain alphanumeric values with exceptions of _-.nnInput Account Name: ";
  16. std::getline(std::cin, inputAccount);
  17. useAccount = inputAccount.substr(0, 15);
  18.  
  19. if (std::all_of(begin(useAccount), end(useAccount), std::isalnum))
  20. {
  21. varAccount = useAccount;
  22. valid = false;
  23. }
  24. }
  25. }
  26. }
  27.  
  28. bool myFun(char a)
  29. {
  30. return (isalnum(a) || a=='_' || a=='-' || a=='.');
  31. }
  32. void AccountData::assignAccount()
  33. {
  34. std::cout << "Input Account Name: ";
  35. std::string inputAccount;
  36. std::getline(std::cin, inputAccount);
  37. std::string useAccount = inputAccount.substr(0, 15);
  38.  
  39. if (std::all_of(begin(useAccount), end(useAccount), myFun)) varAccount = useAccount;
  40. else
  41. {
  42. bool valid = true;
  43.  
  44. while (valid)
  45. {
  46. std::cout << "nAccounts can only contain alphanumeric values with exceptions of _-.nnInput Account Name: ";
  47. std::getline(std::cin, inputAccount);
  48. useAccount = inputAccount.substr(0, 15);
  49.  
  50. if (std::all_of(begin(useAccount), end(useAccount), myFun))
  51. {
  52. varAccount = useAccount;
  53. valid = false;
  54. }
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement