#include#include #ifdef __MINGW32__ #include #endif #define MAX 100 #define BACKSPACE 8 void system_pause(void); int main(void) { char passwords[MAX+1], ch; int i=0; printf("Input the passwords:\n"); #ifdef __MINGW32__ while((ch = getch()) != '\r' && i < MAX) #else system("stty -echo"); while((ch = getchar()) != '\n' && i < MAX) #endif { #ifndef __MINGW32__ system("stty echo"); #endif if (ch == BACKSPACE) { if (i > 0) { passwords[--i] = '\0'; printf("\b "); printf("%c%c%c", BACKSPACE, ' ', BACKSPACE); fflush(stdout); } else printf("\a"); //bell fflush(stdout); } else { passwords[i++] = ch; printf("*"); fflush(stdout); } #ifndef __MINGW32__ system("stty -echo"); #endif } #ifndef __MINGW32__ system("stty echo"); #endif passwords[i] = '\0'; printf("\nYour passwords is: "); printf("%s\n", passwords); system_pause(); return 0; } #ifdef __MINGW32__ void system_pause(void) { system("pause"); } #else void system_pause(void) { puts("Press any key to continue..."); system("stty raw"); getchar(); system("stty cooked"); } #endif
-
归档
- 2025 年 5 月
- 2025 年 4 月
- 2025 年 3 月
- 2025 年 2 月
- 2025 年 1 月
- 2024 年 11 月
- 2024 年 10 月
- 2024 年 8 月
- 2024 年 6 月
- 2024 年 4 月
- 2024 年 3 月
- 2024 年 2 月
- 2024 年 1 月
- 2023 年 12 月
- 2023 年 11 月
- 2023 年 10 月
- 2023 年 9 月
- 2023 年 8 月
- 2023 年 7 月
- 2023 年 6 月
- 2023 年 5 月
- 2023 年 4 月
- 2023 年 3 月
- 2023 年 2 月
- 2023 年 1 月
- 2022 年 12 月
- 2022 年 11 月
- 2022 年 8 月
- 2022 年 7 月
- 2022 年 6 月
- 2022 年 1 月
- 2021 年 12 月
- 2021 年 11 月
- 2021 年 9 月
- 2021 年 7 月
- 2021 年 6 月
- 2021 年 4 月
- 2021 年 3 月
- 2021 年 2 月
- 2021 年 1 月
- 2020 年 12 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 9 月
- 2020 年 8 月
- 2020 年 6 月
- 2020 年 5 月
- 2020 年 3 月
- 2020 年 2 月
- 2020 年 1 月
- 2019 年 12 月
- 2019 年 11 月
- 2019 年 10 月
- 2019 年 9 月
- 2019 年 8 月
- 2019 年 7 月
- 2019 年 6 月
- 2019 年 5 月
- 2019 年 4 月
- 2019 年 3 月
- 2019 年 2 月
- 2019 年 1 月
- 2018 年 12 月
- 2018 年 11 月
- 2018 年 10 月
- 2018 年 8 月
- 2018 年 7 月
- 2018 年 6 月
- 2018 年 5 月
- 2018 年 4 月
- 2018 年 3 月
- 2018 年 2 月
- 2018 年 1 月
- 2017 年 12 月
- 2017 年 11 月
- 2017 年 10 月
- 2017 年 9 月
- 2017 年 8 月
- 2017 年 7 月
- 2017 年 6 月
- 2017 年 5 月
- 2017 年 4 月
- 2017 年 3 月
- 2017 年 1 月
- 2016 年 12 月
- 2016 年 11 月
- 2016 年 10 月
- 2016 年 9 月
- 2016 年 8 月
- 2016 年 7 月
- 2016 年 6 月
- 2016 年 5 月
- 2016 年 4 月
- 2016 年 3 月
- 2016 年 2 月
- 2016 年 1 月
- 2015 年 12 月
- 2015 年 11 月
- 2015 年 10 月
- 2015 年 9 月
- 2015 年 8 月
- 2015 年 7 月
- 2015 年 6 月
- 2015 年 5 月
- 2015 年 4 月
- 2015 年 3 月
- 2015 年 2 月
- 2015 年 1 月
- 2014 年 11 月
- 2014 年 10 月
- 2014 年 9 月
- 2014 年 6 月
- 2014 年 5 月
- 2014 年 4 月
- 2014 年 3 月
- 2014 年 2 月
-
功能