Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void AccountData::assignAccount()
- {
- std::cout << "Input Account Name: ";
- std::string inputAccount;
- std::getline(std::cin, inputAccount);
- std::string useAccount = inputAccount.substr(0, 15);
- if (std::all_of(begin(useAccount), end(useAccount), std::isalnum)) varAccount = useAccount;
- else
- {
- bool valid = true;
- while (valid)
- {
- std::cout << "nAccounts can only contain alphanumeric values with exceptions of _-.nnInput Account Name: ";
- std::getline(std::cin, inputAccount);
- useAccount = inputAccount.substr(0, 15);
- if (std::all_of(begin(useAccount), end(useAccount), std::isalnum))
- {
- varAccount = useAccount;
- valid = false;
- }
- }
- }
- }
- bool myFun(char a)
- {
- return (isalnum(a) || a=='_' || a=='-' || a=='.');
- }
- void AccountData::assignAccount()
- {
- std::cout << "Input Account Name: ";
- std::string inputAccount;
- std::getline(std::cin, inputAccount);
- std::string useAccount = inputAccount.substr(0, 15);
- if (std::all_of(begin(useAccount), end(useAccount), myFun)) varAccount = useAccount;
- else
- {
- bool valid = true;
- while (valid)
- {
- std::cout << "nAccounts can only contain alphanumeric values with exceptions of _-.nnInput Account Name: ";
- std::getline(std::cin, inputAccount);
- useAccount = inputAccount.substr(0, 15);
- if (std::all_of(begin(useAccount), end(useAccount), myFun))
- {
- varAccount = useAccount;
- valid = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement