BLC 사용 예제 - 콘솔에서 숫자로만 이루어진 비밀번호 입력받기
BLC 라이브러리 다운로드
콘솔에서 숫자로만 이루어진 비밀번호를 입력받는 예제 코드입니다.
예제 코드 보기
- #include
-
- #include
- #include
-
- auto check = [](char32_t unicode) {
- return U'0' <= unicode && unicode <= U'9';
- };
-
- int main()
- {
- using namespace blc::console;
- using namespace blc::ustr;
- using namespace std;
-
- SetCharacterWidthFunc(mk_wcwidth_cjk);
-
-
- ConsoleWindow::SetTitle(L"콘솔창에서 숫자 암호 입력받기 예제"s);
-
- auto str = u8""s;
- ConsoleWindow::Space space(0, 0, 60, 1);
-
- cout << u8"숫자만 입력이 가능합니다(ESC 키를 누르면 프로그램이 종료됨)."s << endl << endl;
- while (true) {
- space.set_y(ConsoleWindow::WhereY());
-
- bool is_modified = ConsoleWindow::ModifyStr(str, space, check, '*');
-
-
-
-
- cout << endl << endl;
- if (is_modified) {
- cout << u8"입력받은 비밀번호: "s << str << endl;
- str.clear();
- }
- else {
- cout << u8"비밀번호 입력이 취소됨"s << endl;
- return 0;
- }
- cout << endl << endl;
- }
- }
예제 코드 접기
실행 결과
